Skip to main content

Module verbosity

Module verbosity 

Source
Expand description

Process-wide output level for --quiet / --verbose (dogfood-0.63.0, #2401).

-q, --quiet and -v, --verbose are declared as clap globals on crate::Cli, so clap prints them in the Options block of all 104 subcommands’ --help. Until this module existed nothing read them: in v0.63.0 apr inspect m.apr and apr inspect m.apr --quiet produced byte-identical stdout on 14 of 16 sampled commands, apr hex m.apr --quiet still wrote 303 972 bytes, and apr gbnf-lint ... -q still printed the full PASS report. Only list and lint — the two commands that happened to receive quiet as a parameter — honoured it.

Threading a quiet parameter into every command is the design that already failed: it is the same forwarding bug --offline had (see [crate::commands::offline]), where three commands forgot to pass the flag along and the control was silently inert. So this is a latch, set once in crate::execute_command, plus a crate-wide shadow of println!/print! that consults it. A command cannot disarm --quiet by forgetting to plumb a parameter, because it never receives one.

Semantics:

  • --quiet suppresses ordinary stdout. stderr is untouched, so the error: ... line printed by crate::cli_main and the process exit code both survive — “errors only”, as the help text promises.
  • --quiet does not suppress --json: the JSON document is the machine-readable payload a script asked for, and swallowing it would make --json --quiet useless. stdout_suppressed returns false whenever --json is in effect.
  • A command that implements its own richer quiet semantics opts out of the blanket gate with [emitln!]/[emit!]. Two do: apr list --quiet must still print one model identifier per line (contract apr-list-quiet-wiring-v1 F-LIST-QUIET-001), and apr lint --quiet filters its table down to errors rather than going silent.
  • --verbose raises the level so commands can print detail they otherwise elide; see is_verbose and [vprintln!].
  • --quiet wins over --verbose when both are given.

Structs§

VerbosityScope
RAII guard returned by scope; restores the previous thread values.

Enums§

Level
How much ordinary stdout a run should produce.

Functions§

is_quiet
True iff --quiet was given.
is_verbose
True iff --verbose was given (and --quiet was not).
json_enabled
True iff --json is in effect for this call.
latch
Record the run’s output level. Called once from execute_command.
level
The level in effect for this call.
preamble_lines
The --verbose preamble execute_command prints before dispatching.
resolve
Resolve the two flags into one level.
scope
Override the level for the current thread until the guard drops.
stdout_suppressed
The single decision the shadowed println!/print! consult.