Expand description
Machine mode (--machine) — agent-contract output selector.
See docs/agents/spec.md §10. This
module ships the runtime layer of --machine: pre-parse detection,
clap-error interception, and the canonical ExitCode mapping for
pre-command exits.
Runtime guarantees, regardless of which command is invoked:
- color is disabled (wired through
crate::opts::GlobalArgs::shell), - parse / usage failures are wrapped in an error envelope (
cli.usage.invalid, exit2), --help/--versionare wrapped in a success envelope (exit0).
Per-command behavior — emitting only the declared
output_mode, suppressing progress
bars and interactive prompts, returning the canonical ExitCode for
the failure category — is opt-in and adopted incrementally.
The flag is detected before clap parsing — see check_machine — so
the mode is known by the time clap errors need to be intercepted.
Statics§
Functions§
- bail_
machine_ usage - Emit a
cli.usage.invalidenvelope on stdout and exit withExitCode::Usage(2). Use at call sites that intentionally reject a flag combination under--machine. - bail_
machine_ usage_ with_ details - Like
bail_machine_usagebut attaches structureddetailsso agents can react without parsing the prosemessage. - check_
machine - Pre-parse scan for
--machine. - exit_
code_ 🔒for_ clap_ error - Maps a clap error kind to the canonical
ExitCode. - handle_
machine_ 🔒clap_ error - Convert a clap error into a structured machine-mode envelope and exit.
- is_
machine - Returns whether
--machinewas set on the current invocation. - parse_
or_ exit - Parse arguments, intercepting clap errors when machine mode is on.
- report_
machine_ error - Fallback envelope emitter for an untyped
eyre::Report. Always tagscli.unknownand preserves the eyre cause chain indetails.cause_chain. The process exit code is the caller’s responsibility. - set_
machine 🔒 - Force machine mode on or off. Intentionally crate-private: production
activation goes through
check_machine(pre-parse) orcrate::opts::GlobalArgs::init(post-parse re-sync).