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<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>
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.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.