Skip to content

Commit

Permalink
Always show a hint to skip an automatic update on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
acuteenvy committed Jan 8, 2024
1 parent 37b9fb3 commit d51e0d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ impl Display for Error {
}

impl Error {
pub const DESC_DOWNLOAD_ERR: &'static str = "\n\nA download error occurred. \
pub const DESC_AUTO_UPDATE_ERR: &'static str =
"\n\nAn error occurred during the automatic update. \
To skip updating the cache, run tldr with --offline.";

pub const DESC_LANG_NOT_INSTALLED: &'static str =
Expand Down
7 changes: 2 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use yansi::Paint;
use crate::args::Cli;
use crate::cache::Cache;
use crate::config::Config;
use crate::error::{Error, ErrorKind, Result};
use crate::error::{Error, Result};
use crate::output::PageRenderer;
use crate::util::{infoln, init_color, warnln};

Expand Down Expand Up @@ -87,10 +87,7 @@ fn run() -> Result<()> {
infoln!("cache is stale (last update: {age} ago), updating...");
cache
.update(&mut cfg.cache.languages)
.map_err(|e| match e.kind {
ErrorKind::Download => e.describe(Error::DESC_DOWNLOAD_ERR),
_ => e,
})?;
.map_err(|e| e.describe(Error::DESC_AUTO_UPDATE_ERR))?;
}
}

Expand Down

0 comments on commit d51e0d0

Please sign in to comment.