Skip to content

Commit

Permalink
Fix some problems from rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicHorrorDev committed Jul 9, 2020
1 parent 1ae67d9 commit 19e2905
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,31 +148,22 @@ fn should_update_cache(args: &Args, config: &Config) -> bool {

/// Check the cache for freshness
fn check_cache(args: &Args, enable_styles: bool) {
match Cache::last_update() {
Some(ago) if ago > MAX_CACHE_AGE => {
if args.flag_quiet {
return;
}

// Only use color if enabled
let warning_style = if enable_styles {
Style::new().fg(Color::Yellow)
} else {
Style::default()
};

println!(
"{}",
warning_style.paint(format!(
"The cache hasn't been updated for more than {} days.\n\
You should probably run `tldr --update` soon.",
MAX_CACHE_AGE.as_secs() / 24 / 3600
))
);
match Cache::last_update() {
Some(ago) if ago > MAX_CACHE_AGE => {
if args.flag_quiet {
return;
}

// Only use color if enabled
let warning_style = if enable_styles {
Style::new().fg(Color::Yellow)
} else {
Style::default()
};

eprintln!(
"{}",
Color::Yellow.paint(format!(
warning_style.paint(format!(
"The cache hasn't been updated for more than {} days.\n\
You should probably run `tldr --update` soon.",
MAX_CACHE_AGE.as_secs() / 24 / 3600
Expand Down Expand Up @@ -397,7 +388,7 @@ fn main() {
if args.flag_list {
if !cache_updated {
// Check cache for freshness
check_cache(&args);
check_cache(&args, enable_styles);
}

// Get list of pages
Expand All @@ -421,7 +412,7 @@ fn main() {

if !cache_updated {
// Check cache for freshness
check_cache(&args);
check_cache(&args, enable_styles);
}

// Search for command in cache
Expand Down

0 comments on commit 19e2905

Please sign in to comment.