diff --git a/src/main.rs b/src/main.rs index f077c7c..1480814 100644 --- a/src/main.rs +++ b/src/main.rs @@ -349,20 +349,22 @@ fn try_main(args: Cli, enable_styles: bool) -> Result { } else if args.list || !command.is_empty() { // Cache is needed for these commands to work let Some(cache) = Cache::open(cache_config)? else { - print_error( - enable_styles, - &anyhow::anyhow!( - "Page cache not found. Please run `tldr --update` to download the cache." - ), - ); - println!("\nNote: You can optionally enable automatic cache updates by adding the"); - println!("following config to your config file:\n"); - println!(" [updates]"); - println!(" auto_update = true\n"); - println!("The path to your config file can be looked up with `tldr --show-paths`."); - println!("To create an initial config file, use `tldr --seed-config`.\n"); - println!("You can find more tips and tricks in our docs:\n"); - println!(" https://tealdeer-rs.github.io/tealdeer/config_updates.html"); + if !args.quiet { + print_error( + enable_styles, + &anyhow::anyhow!( + "Page cache not found. Please run `tldr --update` to download the cache." + ), + ); + println!("\nNote: You can optionally enable automatic cache updates by adding the"); + println!("following config to your config file:\n"); + println!(" [updates]"); + println!(" auto_update = true\n"); + println!("The path to your config file can be looked up with `tldr --show-paths`."); + println!("To create an initial config file, use `tldr --seed-config`.\n"); + println!("You can find more tips and tricks in our docs:\n"); + println!(" https://tealdeer-rs.github.io/tealdeer/config_updates.html"); + } return Ok(ExitCode::FAILURE); }; diff --git a/tests/lib.rs b/tests/lib.rs index d431b5f..5b0ec5b 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -468,6 +468,21 @@ fn test_quiet_failures() { .stdout(is_empty()); } +#[test] +fn test_quiet_missing_cache() { + let testenv = TestEnv::new(); + + for args in [["--list", "--quiet"], ["sl", "--quiet"]] { + testenv + .command() + .args(args) + .assert() + .failure() + .stdout(is_empty()) + .stderr(is_empty()); + } +} + #[test] fn test_quiet_old_cache() { let testenv = TestEnv::new().install_default_cache();