Available on crate feature
app only.Expand description
The typed CLI lifecycle: App parses argv, runs a handler, and writes the
result through a View.
App::run reads the process argv and returns the ExitCode for main.
App::run_from takes explicit argv, which tests use. In order, a run:
- answers a
--usage-specrequest from mise, then everyApp::before_parsehook; - warns on stderr about an unusable style or layout variable;
- prints help, or the bare-command help, when the arguments ask for it;
- parses the arguments, with environment variables yielding to flags;
- calls the handler and writes its result, or its error, through the view.
A handler returns a Present value and prints nothing. Help, errors, and
results share one renderer, one theme, and one width policy.
§Exit codes
- A result exits with its
Present::exit_code, 0 by default. - A handler error exits 1.
- A parse error exits with Clap’s code, 2 for a usage error.
- A bare invocation of a command that needs a subcommand or an argument prints the root help to stderr and exits 2.
- A reader that closed the output stream changes the code only under
BrokenPipe::Fail.
Structs§
- App
- One ctl process: short-circuits, help, parsing, execution, and presentation.
Enums§
- Broken
Pipe - How
Appexits when the reader closes stdout or stderr before the output is written, ashead -1does.