pub struct GlobalFlags {
pub json: bool,
}Expand description
Flags injected into every migrated builtin via #[command(flatten)] global: GlobalFlags.
Builtins call parsed.global.apply(ctx) after their own argv parse so the
dispatcher can read the output format post-execute and apply it.
Fields§
§json: boolRender structured output as JSON.
Implementations§
Source§impl GlobalFlags
impl GlobalFlags
Sourcepub fn apply(&self, ctx: &mut dyn ToolCtx)
pub fn apply(&self, ctx: &mut dyn ToolCtx)
Apply the flags to ctx so the dispatcher can pick them up after the
builtin’s execute() returns.
Sourcepub fn apply_from_args(args: &ToolArgs, ctx: &mut dyn ToolCtx)
pub fn apply_from_args(args: &ToolArgs, ctx: &mut dyn ToolCtx)
Honor --json straight off ToolArgs before any per-builtin clap parse.
The kernel calls this just before tool.execute() so the format is set
even when a builtin’s own try_parse_from rejects argv and returns
before parsed.global.apply(ctx) would have run. Idempotent with the
per-builtin apply: both writing OutputFormat::Json yields the same
state.
Trait Implementations§
Source§impl Args for GlobalFlags
impl Args for GlobalFlags
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Append to
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl Clone for GlobalFlags
impl Clone for GlobalFlags
Source§fn clone(&self) -> GlobalFlags
fn clone(&self) -> GlobalFlags
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 GlobalFlags
impl Debug for GlobalFlags
Source§impl Default for GlobalFlags
impl Default for GlobalFlags
Source§fn default() -> GlobalFlags
fn default() -> GlobalFlags
Returns the “default value” for a type. Read more
Source§impl FromArgMatches for GlobalFlags
impl FromArgMatches for GlobalFlags
Source§fn from_arg_matches(
__clap_arg_matches: &ArgMatches,
) -> Result<GlobalFlags, Error>
fn from_arg_matches( __clap_arg_matches: &ArgMatches, ) -> Result<GlobalFlags, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<GlobalFlags, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<GlobalFlags, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches to self.Auto Trait Implementations§
impl Freeze for GlobalFlags
impl RefUnwindSafe for GlobalFlags
impl Send for GlobalFlags
impl Sync for GlobalFlags
impl Unpin for GlobalFlags
impl UnsafeUnpin for GlobalFlags
impl UnwindSafe for GlobalFlags
Blanket Implementations§
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