-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --auto-update flag to allow automatically updating the cache #73
Conversation
… out of date When not updating the cache manually one often gets the following message: Cache wasn't updated in 30 days. You should probably run `tldr --update` soon. The auto-update flag allows to just alias tldr to tldr -a which will automatically update the cache if it is older than the maximum age.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!
}; | ||
}); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to print an information if the cache was successfully updated:
if !args.flag_quiet {
println!("Successfully updated cache.");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but since I don't abort with the '-a' flag when updating fails I'll need to do it with a .map
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, or match :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it with map, didn't see your comment before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest match
would be much more readable in this case. Don't you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the bike-shedding here 😆 I don't like the double OK(_)
pattern with the somewhat unrelated if guard, but I don't care that much. Just decide for the style you prefer most 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you argued with length, and this version is shorter. And I love my bikeshed in darker hues of blue! Light blue is just abhorrent...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if you prefer it, you can also use this:
match cache.update() {
Ok(_) => if !args.flag_quiet => {
println!("Successfully updated cache.");
},
Err(e) => match e {
CacheError(msg) | ConfigError(msg) | UpdateError(msg) => {
eprintln!("Could not update cache: {}", msg)
}
},
}
I think that's actually the nicest shade of medium blue 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbrgn Ping. I applied your favorite shade of medium blue 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I've been sick for the last three days. Will take a look in a few days.
Co-Authored-By: rnestler <raphael.nestler@gmail.com>
Thanks for the update. I thought about this PR a bit. I'm still not sure if the command line flag is the right place for such a setting. It's not something you would want for some command invocations but not for others, so the config file would probably make more sense, right? This would require a slight reorganization of the
The default configuration can be generated with
(The What do you think? Sorry for the change request, but every new flag is a maintenance burden because removing it later is a breaking change, so I want to think twice before adding such new flags... |
The same is true for config options 😉 But probably we want to think about the general configuration concept. Some tools have almost every option configurable via command line, config file and environment variables. But this may or may not make sense for tealdeer. But for the auto update the config file probably makes most sense since it is a rather static option. |
👍 |
Any updates on this? |
The changes outlined in #73 (comment) would need to be implemented. @rnestler are you still interested in implementing those changes, or should we close the PR for now so somebody else can take over? |
This PR is probably the wrong place to implement this anyways. So let's close it and me or somebody else may open a new one. |
Opened an issue at #90. |
When not updating the cache manually one often gets the following
message:
The auto-update flag allows to just alias tldr to tldr -a which will
automatically update the cache if it is older than the maximum age.