b3nj5m1n / xdg-ninja

A shell script which checks your $HOME for unwanted files and directories.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

andrewcrook opened this issue · comments

 "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

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

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.