mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-23 08:34:18 +02:00
Silence the missing-cache message under --quiet (#500)
This commit is contained in:
parent
8bd3a0d4aa
commit
64db5accfa
2 changed files with 31 additions and 14 deletions
30
src/main.rs
30
src/main.rs
|
|
@ -349,20 +349,22 @@ fn try_main(args: Cli, enable_styles: bool) -> Result<ExitCode> {
|
|||
} 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);
|
||||
};
|
||||
|
|
|
|||
15
tests/lib.rs
15
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue