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)]
|
#[derive(Debug, Parser)]
|
||||||
struct Verbosity {
|
struct Verbosity {
|
||||||
#[arg(help = "Verbose output")]
|
#[arg(help = "Verbose output")]
|
||||||
#[arg(short)]
|
#[arg(short, long)]
|
||||||
v: bool,
|
verbose: bool,
|
||||||
|
|
||||||
#[arg(help = "Quiet output. Does not print anything unless it's a error")]
|
#[arg(help = "Quiet output. Does not print anything unless it's a error")]
|
||||||
#[arg(
|
#[arg(
|
||||||
long_help = "Quiet output. Does not print anything unless it's a error. Can be helpful if you pipe the output to stdout"
|
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)]
|
#[arg(short, long)]
|
||||||
q: bool,
|
quiet: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cli_entrypoint() {
|
pub async fn cli_entrypoint() {
|
||||||
let mut cli: Cli = Cli::parse();
|
let mut cli: Cli = Cli::parse();
|
||||||
|
|
||||||
if let Some(verbosity) = &cli.verbosity {
|
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");
|
eprintln!("Output cannot be verbose ('-v') and quiet ('-q') at the same time");
|
||||||
std::process::exit(1)
|
std::process::exit(1)
|
||||||
} else if verbosity.v {
|
} else if verbosity.verbose {
|
||||||
CliLogger::init(LevelFilter::Debug).unwrap()
|
CliLogger::init(LevelFilter::Debug).unwrap()
|
||||||
} else if verbosity.q {
|
} else if verbosity.quiet {
|
||||||
CliLogger::init(LevelFilter::Error).unwrap()
|
CliLogger::init(LevelFilter::Error).unwrap()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue