Add support for optimistic cache functionality, separate cli and config parsing from run #125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, thanks for this wonderful piece of software. I Have been enjoying it for over a year!
However, one particular caveat I have encountered is when I run
tldr
after aa couple of weeks to remind me of e.g. how to use
tar
(that alreadyexists in the cache), I first have to wait to download a cache update prior
I want to see the result already in my local (but stale) cache.
Alternatively, I could use
--offline
, but then I would need to runtldr --update
manually sometimes,I would need to run the command twice for new commands, first with
--offline
and then without.This PR tries to address this by adding a
--optimistic-cache
-flag that, when enabled, adds the following cases:After displaying the result, it runs the update and also communicates to the user if the cache is out of date.
To avoid doing massive amounts of refactoring, I had to do a bit of hack by first
separating CLI and config parsing from the
run
-function, and then in the optimistic cachethe case where the page is not found, call
run
recursively by disabling the optimistic cache flag.Let me know if
--offline
instead.