Rename --quiet to --silent and make --quiet only log errors (#477)

This commit is contained in:
Anders Kaseorg 2022-10-26 16:03:10 -04:00 committed by GitHub
parent a9bcc15797
commit 8fe46f7400
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View file

@ -21,11 +21,14 @@ pub struct Cli {
#[arg(long)] #[arg(long)]
pub config: Option<PathBuf>, pub config: Option<PathBuf>,
/// Enable verbose logging. /// Enable verbose logging.
#[arg(short, long)] #[arg(short, long, group = "verbosity")]
pub verbose: bool, pub verbose: bool,
/// Disable all logging (but still exit with status code "1" upon detecting errors). /// Only log errors.
#[arg(short, long)] #[arg(short, long, group = "verbosity")]
pub quiet: bool, 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. /// Exit with status code "0", even upon detecting errors.
#[arg(short, long)] #[arg(short, long)]
pub exit_zero: bool, pub exit_zero: bool,

View file

@ -220,7 +220,8 @@ fn autoformat(files: &[PathBuf], settings: &Settings) -> Result<usize> {
} }
fn inner_main() -> Result<ExitCode> { fn inner_main() -> Result<ExitCode> {
let cli = Cli::parse(); let mut cli = Cli::parse();
cli.quiet |= cli.silent;
set_up_logging(cli.verbose)?; set_up_logging(cli.verbose)?;
@ -342,7 +343,7 @@ fn inner_main() -> Result<ExitCode> {
tell_user!("Starting linter in watch mode...\n"); tell_user!("Starting linter in watch mode...\n");
let messages = run_once(&cli.files, &settings, !cli.no_cache, false)?; let messages = run_once(&cli.files, &settings, !cli.no_cache, false)?;
if !cli.quiet { if !cli.silent {
printer.write_continuously(&messages)?; printer.write_continuously(&messages)?;
} }
@ -362,7 +363,7 @@ fn inner_main() -> Result<ExitCode> {
tell_user!("File change detected...\n"); tell_user!("File change detected...\n");
let messages = run_once(&cli.files, &settings, !cli.no_cache, false)?; let messages = run_once(&cli.files, &settings, !cli.no_cache, false)?;
if !cli.quiet { if !cli.silent {
printer.write_continuously(&messages)?; printer.write_continuously(&messages)?;
} }
} }
@ -388,13 +389,13 @@ fn inner_main() -> Result<ExitCode> {
let path = Path::new(&filename); let path = Path::new(&filename);
( (
run_once_stdin(&settings, path, cli.fix)?, run_once_stdin(&settings, path, cli.fix)?,
!cli.quiet && !cli.fix, !cli.silent && !cli.fix,
false, false,
) )
} else { } else {
( (
run_once(&cli.files, &settings, !cli.no_cache, cli.fix)?, run_once(&cli.files, &settings, !cli.no_cache, cli.fix)?,
!cli.quiet, !cli.silent,
!cli.quiet, !cli.quiet,
) )
}; };