tldr-pages / tldr-python-client

Python command-line client for tldr pages
https://pypi.org/project/tldr/
MIT License
596 stars 93 forks source link

Allow `TLDR_PAGES_SOURCE_LOCATION` to contain multiple locations #188

Open scottmuc opened 2 years ago

scottmuc commented 2 years ago

In my work environment, I'm maintaining a fork of tldr-pages to add pages that are private and not ever intended to be merged upstream. In order to not have to maintain a fork, I'd be interested in maintaining a sparse replica that only contains the pages are company maintains.

I was thinking that the variable could be set as follows:

TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/master/pages;https://raw.githubusercontent.com/big-corp/tldr/master/pages"

or

TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/master/pages;${HOME}/.tldr/pages

In the above ${HOME}/.tldr is a clone of github.com/big-corp/tldr.

For duplicates or conflicts, I can see a few ways of managing:

Curious what people think. I'd be happy to implement this if the maintainers feel like this could be a workable feature.

Here's my tldr shim I use:

#!/usr/bin/env bash

set -e
set -o pipefail

if [[ ! -d ~/.tldr ]]; then
  echo "Fetching tldr-pages from GitHub..."
  # Use public repo until I have something to hide ;-)
  # Would need to display a useful message if keys aren't loaded
  git clone https://github.com/scottmuc/tldr.git ~/.tldr 2> /dev/null
fi

if [[ "$1" = "--update_cache" || "$1" = "-u" ]]; then
  echo "Updating tldr-pages from GitHub..."
  ( cd ~/.tldr && git pull )
else
  # Disable the cache so standard tldr-pages repo and zip aren't used
  env \
    TLDR_CACHE_ENABLED=0 \
    TLDR_PAGES_SOURCE_LOCATION="file://${HOME}/.tldr/pages" \
    "${HOMEBREW_PREFIX}/bin/tldr" "$@"
fi

and here's it in action:

~ ? tldr muc

  muc

  Scott Muc's cheat sheet.
  More information: https://github.com/scottmuc/tldr/.

  - Initalize 1Password:
    initalize-1password

The reason why this feature in the client would be useful is to remove the need to maintain a fork of the pages as well as providing a home for the additional pages that's not surrounded my upstream maintained files.

scottmuc commented 2 years ago

Looking at the other issues, this may assist in helping out the folks that submitted #147 and #146