Skip to content
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

TLDR - C client does have an environment variable to select cache directory location #295

Closed
andrewcrook opened this issue Jul 22, 2023 · 2 comments · Fixed by #352
Closed

Comments

@andrewcrook
Copy link

andrewcrook commented Jul 22, 2023

 "help": "Currently tldr-pages do not have any specification for clients on where to cache tldr-pages. See the relevant [issue](https://github.com/tldr-pages/tldr/issues/876) and [specification](https://github.com/tldr-pages/tldr/blob/main/CLIENT-SPECIFICATION.md)\n\nOfficial tldr-nodejs-client, tldr-python-client or tldr-c-client do not support XDG Base Directories.\n\n**Use [Tealdeer](https://github.com/dbrgn/tealdeer), a rust client for tldr that supports XDG Base Directories instead.**\n”

source

whilst the tldr c client doesnt use XDG it does look for the following environment variable to store the cache

TLDR_CACHE_DIR

This can be used, for example, to achieve

TLDR_CACHE_DIR=“$XDG_CACHE_HOME/tldrc”
gethome(void)
{
    char const *homedir = NULL;
    struct passwd *uid;

    if ((homedir = getenv("TLDR_CACHE_DIR")) != NULL)
        return homedir;

/* see code for the rest ....  */

    return homedir;
}

source

@flexagoon
Copy link
Contributor

Is this feature only available in the C client? How can users determine which client they're using?

@andrewcrook
Copy link
Author

andrewcrook commented Jan 27, 2024

Is this feature only available in the C client?

Yes looks like it, despite being in the same GitHub account it looks like there are differences in specification between ports.

tldr-c-client - uses $TLDR_CACHE_DIR

tldr-python-client - already uses XDG_CACHE_HOME
https://github.com/tldr-pages/tldr-python-client/blob/1ba127a4408376ebc0957590476edf99554b7601/tldr.py#L80

tldr-Node - doesn’t support XDG looks hardwired to $HOME/.tldr
tldr-pages/tldr-node-client#346
https://github.com/tldr-pages/tldr-node-client/blob/d38403c0be60898da67ec049ed1241c1f7a9dabe/lib/config.js#L15

tldrc (The Rust Client) - Uses the package dirs I believe this to support XDG (however, I am not sure how this packages deals with macOS it isnt clear enough, that is, if XDG overrides the Apple recommended folders as these are mentioned in the docs)
https://crates.io/crates/dirs

How can users determine which client they're using?

Good point and I bet there are already examples of this issue?

There are a number of ways to identify scripts and binaries you could use file it seems to identify some binary types and for scripts file probably uses a mixture of mime types, file extensions and hash bangs).

with binaries there are other options for example Rust binaries have paths of .rs files as strings in the binaries for rust panics so a using strings and grep could be an option. Go binaries have similar fingerprints I believe around FMT files. Different C/C++ compilers might be more difficult.

If you need that then binary and script types should probably be a new feature for conditionals in the database just like OS type probably should be.

could package manager detection and the package managers give this information?

But this is probably getting too complex for the project.

flexagoon added a commit to flexagoon/xdg-ninja that referenced this issue Feb 3, 2024
b3nj5m1n pushed a commit that referenced this issue Feb 3, 2024
* add tuist (#272)

* add cocoapods (#270)

* add swiftpm (#269)

* add missing newline to tuist.json

* add ash (#283)

* add help for expo

* set correct android env vars (#32, #342)

* add scriptkit (#297)

* update xdg-utils message (#300)

* fix ipython error in pythonrc (#289)

* zsh directories need to be created manually (#341)

* add instructions for dotnet (#349)

* simplify emacs instructions (#315)

* ash: directory must be created manually

* add instructions for tldrc (#295)

* add a warning for xinitrc and Xauthority (#274)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants