Expand description

Control log level with a --verbose flag for your CLI


To get --quiet and --verbose flags through your entire program, just flatten Verbosity:

verbose: Verbosity,

You can then use this to configure your logger:

let cli = Cli::parse();

By default, this will only report errors.

  • -q silences output
  • -v show warnings
  • -vv show info
  • -vvv show debug
  • -vvvv show trace

You can also customize the default logging level:

use clap_verbosity_flag::{Verbosity, InfoLevel};

/// Le CLI
#[derive(Debug, Parser)]
struct Cli {
    verbose: Verbosity<InfoLevel>,

Or implement LogLevel yourself for more control.