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, raw_argv: bool, ctx: &mut dyn ToolCtx)
pub fn apply_from_args(args: &ToolArgs, raw_argv: bool, 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.
raw_argv is ToolSchema::raw_argv
for the tool being dispatched, and it decides whether positional is
searched at all. Only a raw_argv tool keeps --json — and the --
marker that bounds it — among its positionals. For every other tool a
positional --json got there by being an operand after --, where the
binder drops the marker, so searching would read the operand back as
the kernel’s flag and echo -- --json hi would answer in JSON.
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
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl FromArgMatches for GlobalFlags
impl FromArgMatches for GlobalFlags
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, 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>
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>
ArgMatches to self.