Skip to main content

Module app

Module app 

Source
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:

  1. answers a --usage-spec request from mise, then every App::before_parse hook;
  2. warns on stderr about an unusable style or layout variable;
  3. prints help, or the bare-command help, when the arguments ask for it;
  4. parses the arguments, with environment variables yielding to flags;
  5. 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§

BrokenPipe
How App exits when the reader closes stdout or stderr before the output is written, as head -1 does.