Add note about auto-updates when cache is missing (#254)

This commit is contained in:
Danilo Bargen 2022-02-06 22:53:48 +01:00 committed by GitHub
commit 5a1a21b8ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View file

@ -81,10 +81,20 @@ fn check_cache(args: &Args, enable_styles: bool) -> CheckCacheResult {
CheckCacheResult::CacheFound
}
CacheFreshness::Missing => {
print_warning(
print_error(
enable_styles,
"Cache not found. Please run `tldr --update`.",
&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://dbrgn.github.io/tealdeer/config_updates.html");
CheckCacheResult::CacheMissing
}
}

View file

@ -131,7 +131,7 @@ fn test_missing_cache() {
.args(["sl"])
.assert()
.failure()
.stderr(contains("Cache not found. Please run `tldr --update`."));
.stderr(contains("Page cache not found. Please run `tldr --update`"));
}
#[test]
@ -143,7 +143,7 @@ fn test_update_cache() {
.args(["sl"])
.assert()
.failure()
.stderr(contains("Cache not found. Please run `tldr --update`."));
.stderr(contains("Page cache not found. Please run `tldr --update`"));
testenv
.command()
@ -518,7 +518,7 @@ fn test_list_flag_rendering() {
.args(["--list"])
.assert()
.failure()
.stderr(contains("Cache not found. Please run `tldr --update`."));
.stderr(contains("Page cache not found. Please run `tldr --update`"));
testenv.add_entry("foo", "");
@ -551,7 +551,7 @@ fn test_autoupdate_cache() {
.args(["--list"])
.assert()
.failure()
.stderr(contains("Cache not found. Please run `tldr --update`."));
.stderr(contains("Page cache not found. Please run `tldr --update`"));
let config_file_path = testenv.config_dir.path().join("config.toml");
let cache_file_path = testenv.cache_dir.path().join(TLDR_PAGES_DIR);