-
-
Couldn't load subscription status.
- Fork 20
Add support for deferring auto update after page render #125
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
Conversation
If that delay annoys you, then you can always set up something to run [Unit]
Description=Update the cache of tldr pages
After=network.target
[Service]
Type=oneshot
ExecStart=tldr --update
[Install]
WantedBy=default.targetPut that in As for this PR, yeah the recursive Let's get some more opinions though, I'll wait for other maintainers. |
Yeah, found out about Nevertheless, if this is deemed worthwhile, I can do the work to remove the hacky recursiveness, but I'll wait for confirmation before doing that if this is a wanted feature or not. |
|
@acuteenvy Hmm for macOS and Windows it would be a different syntax, not ideal when managing one's dotfiles. I also find it a bit of an annoyance. IMO the cache update should happen after the command or in parallel, not before because it means having to wait a bit which can interrupt the flow. It's not a huge thing, just a little thing that I think would be nice. |
|
@acuteenvy Commenting to say that I also find waiting for tldr to update sufficiently annoying and if you're not someone that's already a regular tldr user having to wait for it to update when you do decide to try out can be enough to turn a user off from making tldr their go to quick command info finder tldr should feel fast to run or users everytime imo. speed is the point of using something like tldr. hope this gets implemented |
|
@acuteenvy made some progress on cleaning this up, but I got lost in doing other things to separate the logic from the ' run `function. The optimistic cache update is now running during the drop of the cache, provided it was deemed necessary, and only if it is still necessary to run it. Marked commit as wip as I would like to write some tests for this, but I'm unsure when I have the time. |
…ig parsing from run function
7ee4557 to
1b05f86
Compare
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.
Alright, since some more people said this feature is useful, I think we can implement it. I have a couple suggestions though:
- I think having this in the config is enough. This feature isn't something that a user will frequently change, so a command-line option isn't necessary.
impl Drop for Cacheisn't a very good place to put page updating code into, because you can't return errors from it.- The name
optimistic_cachedoesn't really explain what this option does. How aboutdefer_auto_update?
I can try fixing the original recursive run workaround and the issues I've pointed out if you want to.
and remove recursion
Let me know if there is something that you'd like to see added/changed, or feel free to make edits/fix the original version as well, I'm fine with any option as long as this feature gets added 👍 |
|
I tried to solve the issues of your original version. I think it works as intended, could you test whether it works for you? |
Hey, tested it and yeah, this one works as intended 👍 thanks for fixing it! |
This should be re-added after a new release
|
Thank you! |
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
tldrafter 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 --updatemanually sometimes,I would need to run the command twice for new commands, first with
--offlineand 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
runrecursively by disabling the optimistic cache flag.Let me know if
--offlineinstead.