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
Use without cache? #34
Comments
That's an interesting thought. It'd require two To clarify, is your intent to make sure tldr never touches the local filesystem? Or are you aiming for a simplification of what the script is currently doing? |
That's what I intented. I thought about that after I found cheat.sh Two curl requests is fine, I think. |
Would you be okay if it required an explicit switch and/or an environment variable to enable that mode? Say "export TLDR_NOCACHE=1" or something? It should be a relatively straightforward change but I'd like to keep the defaults using the cache. |
Yes, it's OK!
|
I've added this into the client in f56b013 The commit describes how to use it: Add a mode which downloads the page from github every time, with caveats. Enable with '-n' or the environment variable TLDR_CACHE=no. eg, add
This will cause tldr to directly curl the requested page from GitHub This mode is not recommended for common usage. |
Great! Good job. What about using personal token to bypass github rate limits? If you agree, I'm willing to make a PR ( on some weekend). |
That could work. Have you decided whether that's necessary yet? (Meaning, have you hit the rate limit issue?) |
Not hit yet. Maybe that can be left there for now. |
It seems f56b013 isn't quite the full story yet, unfortunately: Currently, the only workaround I see would be to split argument parsing and actual actions (list/fetch/update/…) into two steps, so we can first decide whether to use the cache and only then do anything the might try to use the cache. Without that, cache usage would depend on the order of arguments ( Oh the joys of orthogonal features… |
Good catch. Adding something like the below before handling the flags would be a start. flagged() {
flag=$1
shift
for i do
case $i in
"$flag") true; return ;;
esac
done
false
}
if flagged -n "$@"; then
TLDR_CACHE=no
fi Making --list useful without a cache or touching the filesystem at all is a bit tricky. The tldr pages archive is ~1.2MB, index.json itself is ~200K. I can't see anyone wanting to download that every time they do a list. Or would you? What's your use case look like for this? |
Wow, that was quick! As for my use case: I originally looked at this issue because I wanted to add a tldr client to my default shell config, but avoid having it use disk space for a lot of tldr pages, most of which I'll likely never need. (The cache directory is 15 MiB at the moment, after all.) I don't immediately see a clean universal solution, so just throwing some ideas around…
|
Yeah, this original issue was to have tldr not touch the filesystem at all. That doesn't preclude another environment option or switch to get the behavior you'd like, of course. But I'd like to not add a third option in the future when someone else points out I forgot another use case for slimming it down further :-) For saving disk space but still allowing completions (which seems good), I think pulling down the list and extracting just the bits the script needs seems workable. Though I'm glad someone else shares my pain about This tldr client has an update option to force downloading fresh pages before the default cache expiration time, so that's sorted too. So I think we're down to a parameter that tells tldr to get just the index.json and use that for its queries (perhaps with preprocessing). Can you think of any variations we're forgetting? |
Thinking about this more, the right solution is probably an environment variable which dictates what should be kept from the archive, and what should be tossed. That would generalize for handling different languages as well. |
The new version of the script relies upon the local filesystem to generate a listing. As it's a bit of surgery to remove that assumption I'm going to close this feature as "close enough". |
Would there be a feature using without cache?
Just directly
curl
the page and display it.The text was updated successfully, but these errors were encountered: