mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Fix verbosity not applied if flag is used globally
This commit is contained in:
parent
fbe182239a
commit
937e9a2fdc
1 changed files with 7 additions and 7 deletions
|
|
@ -36,7 +36,7 @@ trait Execute {
|
||||||
#[clap(name = "crunchy-cli")]
|
#[clap(name = "crunchy-cli")]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
verbosity: Option<Verbosity>,
|
verbosity: Verbosity,
|
||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
help = "Overwrite the language in which results are returned. Default is your system language"
|
help = "Overwrite the language in which results are returned. Default is your system language"
|
||||||
|
|
@ -116,13 +116,13 @@ struct Verbosity {
|
||||||
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 cli.verbosity.verbose || cli.verbosity.quiet {
|
||||||
if verbosity.verbose as u8 + verbosity.quiet as u8 > 1 {
|
if cli.verbosity.verbose && cli.verbosity.quiet {
|
||||||
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.verbose {
|
} else if cli.verbosity.verbose {
|
||||||
CliLogger::init(LevelFilter::Debug).unwrap()
|
CliLogger::init(LevelFilter::Debug).unwrap()
|
||||||
} else if verbosity.quiet {
|
} else if cli.verbosity.quiet {
|
||||||
CliLogger::init(LevelFilter::Error).unwrap()
|
CliLogger::init(LevelFilter::Error).unwrap()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -134,14 +134,14 @@ pub async fn cli_entrypoint() {
|
||||||
match &mut cli.command {
|
match &mut cli.command {
|
||||||
Command::Archive(archive) => {
|
Command::Archive(archive) => {
|
||||||
// prevent interactive select to be shown when output should be quiet
|
// prevent interactive select to be shown when output should be quiet
|
||||||
if cli.verbosity.is_some() && cli.verbosity.as_ref().unwrap().quiet {
|
if cli.verbosity.quiet {
|
||||||
archive.yes = true;
|
archive.yes = true;
|
||||||
}
|
}
|
||||||
pre_check_executor(archive).await
|
pre_check_executor(archive).await
|
||||||
}
|
}
|
||||||
Command::Download(download) => {
|
Command::Download(download) => {
|
||||||
// prevent interactive select to be shown when output should be quiet
|
// prevent interactive select to be shown when output should be quiet
|
||||||
if cli.verbosity.is_some() && cli.verbosity.as_ref().unwrap().quiet {
|
if cli.verbosity.quiet {
|
||||||
download.yes = true;
|
download.yes = true;
|
||||||
}
|
}
|
||||||
pre_check_executor(download).await
|
pre_check_executor(download).await
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue