Skip to content

Commit

Permalink
Add note about auto-updates when cache is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn committed Feb 5, 2022
1 parent 716ff15 commit b85625f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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()
Expand Down Expand Up @@ -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", "");

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b85625f

Please sign in to comment.