mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add long flag options to -v and -q (--verbose and --quiet)
This commit is contained in:
parent
fc44b8af8a
commit
75b6e7b452
1 changed files with 7 additions and 7 deletions
|
|
@ -90,27 +90,27 @@ enum Command {
|
|||
#[derive(Debug, Parser)]
|
||||
struct Verbosity {
|
||||
#[arg(help = "Verbose output")]
|
||||
#[arg(short)]
|
||||
v: bool,
|
||||
#[arg(short, long)]
|
||||
verbose: bool,
|
||||
|
||||
#[arg(help = "Quiet output. Does not print anything unless it's a error")]
|
||||
#[arg(
|
||||
long_help = "Quiet output. Does not print anything unless it's a error. Can be helpful if you pipe the output to stdout"
|
||||
)]
|
||||
#[arg(short)]
|
||||
q: bool,
|
||||
#[arg(short, long)]
|
||||
quiet: bool,
|
||||
}
|
||||
|
||||
pub async fn cli_entrypoint() {
|
||||
let mut cli: Cli = Cli::parse();
|
||||
|
||||
if let Some(verbosity) = &cli.verbosity {
|
||||
if verbosity.v as u8 + verbosity.q as u8 > 1 {
|
||||
if verbosity.verbose as u8 + verbosity.quiet as u8 > 1 {
|
||||
eprintln!("Output cannot be verbose ('-v') and quiet ('-q') at the same time");
|
||||
std::process::exit(1)
|
||||
} else if verbosity.v {
|
||||
} else if verbosity.verbose {
|
||||
CliLogger::init(LevelFilter::Debug).unwrap()
|
||||
} else if verbosity.q {
|
||||
} else if verbosity.quiet {
|
||||
CliLogger::init(LevelFilter::Error).unwrap()
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue