pub struct CliContext {
pub raw: Vec<String>,
pub domain: Option<String>,
pub resource: Option<String>,
pub verb: Option<String>,
pub target: Option<String>,
pub args: Vec<String>,
pub flags: HashMap<String, String>,
}Expand description
CLI execution context after parsing.
Holds the parsed command components and provides ergonomic helpers for flag lookup, output format detection, etc.
Fields§
§raw: Vec<String>Full argument vector after red
domain: Option<String>Primary command (e.g. “server”, “query”, “health”)
resource: Option<String>Resource within the domain (e.g. collection name)
verb: Option<String>Verb or action to perform
target: Option<String>Optional target (id, query string, etc.)
args: Vec<String>Additional positional arguments beyond the target
flags: HashMap<String, String>Parsed flags (--flag=value, -f value, etc.)
Implementations§
Source§impl CliContext
impl CliContext
pub fn new() -> CliContext
Sourcepub fn get_flag_or(&self, key: &str, default: &str) -> String
pub fn get_flag_or(&self, key: &str, default: &str) -> String
Get a flag value or return a default.
Sourcepub fn domain_only(&self) -> Option<&str>
pub fn domain_only(&self) -> Option<&str>
Get the domain only (first positional).
Sourcepub fn wants_json(&self) -> bool
pub fn wants_json(&self) -> bool
Check if JSON output was explicitly requested.
Sourcepub fn wants_machine_output(&self) -> bool
pub fn wants_machine_output(&self) -> bool
Check if machine-readable output was requested (JSON or YAML).
Sourcepub fn get_output_format(&self) -> OutputFormat
pub fn get_output_format(&self) -> OutputFormat
Get the output format from flags or default to human.
Trait Implementations§
Source§impl Clone for CliContext
impl Clone for CliContext
Source§fn clone(&self) -> CliContext
fn clone(&self) -> CliContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CliContext
impl Debug for CliContext
Source§impl Default for CliContext
impl Default for CliContext
Source§fn default() -> CliContext
fn default() -> CliContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Forget for CliContext
impl Freeze for CliContextwhere
*const u8 is !null: Freeze,
PhantomData<String>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<(String, String)>: Freeze,
impl Move for CliContext
impl RefUnwindSafe for CliContext
impl Send for CliContext
impl Sync for CliContext
impl Unpin for CliContext
impl UnsafeUnpin for CliContextwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
impl UnwindSafe for CliContext
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request