From 8fe46f7400a34aa489bce586b701a478442d9517 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 26 Oct 2022 16:03:10 -0400 Subject: [PATCH] Rename --quiet to --silent and make --quiet only log errors (#477) --- src/cli.rs | 9 ++++++--- src/main.rs | 11 ++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index bcfd92ced1..991008fcb0 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -21,11 +21,14 @@ pub struct Cli { #[arg(long)] pub config: Option, /// Enable verbose logging. - #[arg(short, long)] + #[arg(short, long, group = "verbosity")] pub verbose: bool, - /// Disable all logging (but still exit with status code "1" upon detecting errors). - #[arg(short, long)] + /// Only log errors. + #[arg(short, long, group = "verbosity")] pub quiet: bool, + /// Disable all logging (but still exit with status code "1" upon detecting errors). + #[arg(short, long, group = "verbosity")] + pub silent: bool, /// Exit with status code "0", even upon detecting errors. #[arg(short, long)] pub exit_zero: bool, diff --git a/src/main.rs b/src/main.rs index f56c4c62e2..9d11f2ae57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -220,7 +220,8 @@ fn autoformat(files: &[PathBuf], settings: &Settings) -> Result { } fn inner_main() -> Result { - let cli = Cli::parse(); + let mut cli = Cli::parse(); + cli.quiet |= cli.silent; set_up_logging(cli.verbose)?; @@ -342,7 +343,7 @@ fn inner_main() -> Result { tell_user!("Starting linter in watch mode...\n"); let messages = run_once(&cli.files, &settings, !cli.no_cache, false)?; - if !cli.quiet { + if !cli.silent { printer.write_continuously(&messages)?; } @@ -362,7 +363,7 @@ fn inner_main() -> Result { tell_user!("File change detected...\n"); let messages = run_once(&cli.files, &settings, !cli.no_cache, false)?; - if !cli.quiet { + if !cli.silent { printer.write_continuously(&messages)?; } } @@ -388,13 +389,13 @@ fn inner_main() -> Result { let path = Path::new(&filename); ( run_once_stdin(&settings, path, cli.fix)?, - !cli.quiet && !cli.fix, + !cli.silent && !cli.fix, false, ) } else { ( run_once(&cli.files, &settings, !cli.no_cache, cli.fix)?, - !cli.quiet, + !cli.silent, !cli.quiet, ) };