Giter Site home page Giter Site logo

tldr-pages / tldr-python-client Goto Github PK

View Code? Open in Web Editor NEW
585.0 19.0 91.0 224 KB

Python command-line client for tldr pages

Home Page: https://pypi.org/project/tldr/

License: MIT License

Python 100.00%
tldr python tldr-pages tldr-python-client hacktoberfest

tldr-python-client's Introduction

tldr-python-client

PyPI Release Build

Python command-line client for tldr pages.

tldr pages example

Installation

Check Repology Packaging Status! Packaging status

from PyPI

pip install tldr

from Arch Linux repository

sudo pacman -S tldr

from Fedora packages repository

sudo dnf install tldr

from Snap Store

sudo snap install tldr

Usage

usage: tldr command [options]

Python command line client for tldr

positional arguments:
  command               command to lookup

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --search "KEYWORDS"   Search for a specific command from a query
  -u, --update, --update_cache
                        Update the local cache of pages and exit
  -p PLATFORM, --platform PLATFORM
                        Override the operating system [linux, osx, sunos, windows, common]
  -l, --list            List all available commands for operating system
  -s SOURCE, --source SOURCE
                        Override the default page source
  -c, --color           Override color stripping
  -r, --render          Render local markdown files
  -L LANGUAGE, --language LANGUAGE
                        Override the default language
  -m, --markdown        Just print the plain page file.
  --print-completion {bash,zsh,tcsh}
                        print shell completion script

Configuration

You can configure the behavior and output of the tldr client by setting environment variables. For example, in the .bashrc file:

export TLDR_COLOR_NAME="cyan"
export TLDR_COLOR_DESCRIPTION="white"
export TLDR_COLOR_EXAMPLE="green"
export TLDR_COLOR_COMMAND="red"
export TLDR_COLOR_PARAMETER="white"
export TLDR_LANGUAGE="es"
export TLDR_CACHE_ENABLED=1
export TLDR_CACHE_MAX_AGE=720
export TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/main/pages"
export TLDR_DOWNLOAD_CACHE_LOCATION="https://tldr-pages.github.io/assets/tldr.zip"

Cache

Cache is downloaded from TLDR_DOWNLOAD_CACHE_LOCATION (defaults to the one described in the client specification), unzipped and extracted into the local cache directory. Pages are loaded directly from TLDR_PAGES_SOURCE_LOCATION if tldr <command> is used.

  • TLDR_CACHE_ENABLED (default is 1):
    • If set to 1, the client will first try to load from cache, and fall back to fetching from the internet if the cache doesn't exist or is too old.
    • If set to 0, the client will fetch from the internet, and fall back to the cache if the page cannot be fetched from the internet.
  • TLDR_CACHE_MAX_AGE (default is 168 hours, which is equivalent to a week): maximum age of the cache in hours to be considered as valid when TLDR_CACHE_ENABLED is set to 1.

Cache location

In order of precedence:

  • $XDG_CACHE_HOME/tldr
  • $HOME/.cache/tldr
  • ~/.cache/tldr

If you are experiencing issues with tldr, consider deleting the cache files before trying other measures.

Autocomplete

shtab is required for autocompletion using the --print-completion argument.

# bash
tldr --print-completion bash | sudo tee "$BASH_COMPLETION_COMPAT_DIR"/tldr
# zsh (it is recommended to check where zsh/site-functions directory is located)
## for macOS:
tldr --print-completion zsh | sudo tee /usr/local/share/zsh/site-functions/_tldr
## for Linux:
tldr --print-completion zsh | sudo tee /usr/share/zsh/site-functions/_tldr

See the shtab docs for other installation methods and supported shells.

For autocomplete in fish, while it is not supported in shtab yet, please see #183 for manually adding an autocomplete for tldr for fish.

SSL Inspection

For networks that sit behind a proxy, it may be necessary to disable SSL verification for the client to function. Setting the following:

  • TLDR_ALLOW_INSECURE=1

will disable SSL certificate inspection. This should be avoided unless absolutely necessary.

Colors

Values of the TLDR_COLOR_x variables may consist of three parts:

  • Font color: blue, green, yellow, cyan, magenta, white, grey, red
  • Background color: on_blue, on_cyan, on_magenta, on_white, on_grey, on_yellow, on_red, on_green
  • Additional effects, which depend on the platform: reverse, blink, dark, concealed, underline, bold

You may specify as many additional effects as you want, while only one of font and background color.

Any of the values above may be omitted. For example, you can do similar things as the following:

  • TLDR_COLOR_NAME="" use default system font color with default background color without any effects
  • TLDR_COLOR_DESCRIPTION="white" for white text on default system background color without any effects
  • TLDR_COLOR_NAME="cyan dark" for dark cyan text on default system background color
  • TLDR_COLOR_NAME="on_red" for default system font color on the red background color
  • TLDR_COLOR_PARAMETER="red on_yellow underline" for underlined red text on yellow background
  • TLDR_COLOR_NAME="bold underline" for default system font and background colors with underline and bolded effects

Language

The language that tldr will use is dependent on several factors. If you specify a language via the --language flag, tldr will attempt to use that language and only that language. Otherwise, it will try to use the language specified by TLDR_LANGUAGE. If it is not set, or the page does not exist in that language, then tldr will use the language set using LANGUAGE and LANG (ignoring the values C and POSIX).

If neither is set, then tldr will always attempt to get the en page. Finally, if LANG is set, it uses LANGUAGE, if set, first, as the priority list to try languages in, followed by LANG if not included in LANGUAGE and en as a fallback (assuming it does not already appear somewhere in LANGUAGE or LANG).

All language values should be set to a value that follows RFC 1766, with the special exceptions of C and POSIX which are ignored.

Remote source

If you wish to use your own instance of the tldr pages instead of the default repository, you can either use the --source flag when using tldr or by specifying the following environment variables:

  • TLDR_PAGES_SOURCE_LOCATION to control where to get individual pages from.
    • defaults to https://raw.githubusercontent.com/tldr-pages/tldr/main/pages.
    • it can also point to a local directory using file:///path/to/directory.
  • TLDR_DOWNLOAD_CACHE_LOCATION to control where to pull a zip of all pages from.
    • defaults to https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip.

tldr-python-client's People

Contributors

anakimluke avatar anmol-singh-jaggi avatar bl-ue avatar bwh1te avatar cleanmachine1 avatar columbarius avatar dadav avatar felixonmars avatar franga2000 avatar frenzymadness avatar gotlougit avatar iliakonnov avatar jaimepas77 avatar kbdharun avatar lots0logs avatar masterodin avatar mdshw5 avatar mohammad7t avatar nebnola avatar onovy avatar owenvoke avatar pacohh avatar ramwin avatar samuel-w avatar saurabhdrao avatar shrayasr avatar vitorhcl avatar waldyrious avatar wcheang avatar zlatanvasovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tldr-python-client's Issues

ValueError: need more than 0 values to unpack while running manage.status

Hello,

I have a salt-master. I also have a minion, running not on the same machine with the master, but instead, it is a separate box sitting on the same network. I have not accepted the key of that minion on salt-master side. Here are the keys on the master side:

salt-key -l all
Accepted Keys:
Denied Keys:
Unaccepted Keys:
BL1706002
Rejected Keys:

Minion-id of my minion is BL1706002.

When I run the manage.status command on the master side I get the following error:

salt-run manage.status
No minions matched the target. No command was sent, no jid was assigned.
Exception occurred in runner manage.status: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/client/mixins.py", line 395, in _low
    data['return'] = self.functions[fun](*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/runners/manage.py", line 73, in status
    ret['up'], ret['down'] = _ping(tgt, expr_form, __opts__['timeout'])
ValueError: need more than 0 values to unpack

This used to work. But I recently started getting this error and this error is breaking the UI of the application that I am developing. I can make my code to catch this error, digest it and gracefully continue as if there were no problems, but it didn't sound a correct solution to go with to me. So, instead, I wanted to ask you guys, what your opinions are.

Is this the normal behavior? Am I missing something ? What do you guys suggest?

Thank you very much

PS: Extra information

salt-master --version
salt-master 2016.11.2 (Carbon)
uname -a
Linux xxxxxxxxxxxx 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 GNU/Linux

no internet connection detected when invalid color

On Arch Linux, when i set a invalid color e.g.
export TLDR_COLOR_PARAMETER="black"
and then do tldr tar, it stops as soon as the color would be used, but with the confusing message:
No internet connection detected. Please reconnect and try again.
Tested with the repo package and the git version.

Not able to install using pip

This is strange. I'm able to find the package in https://pypi.python.org/ , but if I try to install it using pip or easy_install, it fails saying it can't be found.
I'm under Ubuntu 13.04.

Commands output:

โฎ€ sudo pip install tldr
Downloading/unpacking tldr
  Could not find any downloads that satisfy the requirement tldr
No distributions at all found for tldr
Storing complete log in /home/fisa/.pip/pip.log

โฎ€ sudo easy_install tldr
Searching for tldr
Reading https://pypi.python.org/simple/tldr/
No local packages or download links found for tldr
error: Could not find suitable distribution for Requirement.parse('tldr')

403 forbidden on --download_cache

The regular use case works fine, but --download_cache doesn't:

$ tldr --download_cache
Error: Unable to update cache from tldr site

I checked the code, and the error is hidden behind a very general except:

def download_cache():
    cache_path = get_cache_dir()
    if not os.path.exists(cache_path):
        return
    try:
        req = urlopen(DOWNLOAD_CACHE_LOCATION)
        zipfile = ZipFile(BytesIO(req.read()))
        pattern = re.compile(r'pages/(.+)/(.+)\.md')
        cached = 0
        for entry in zipfile.namelist():
            match = pattern.match(entry)
            if match:
                store_page_to_cache(zipfile.read(entry), match.group(2), match.group(1))
                cached += 1
        print("Updated cache for {:d} entries".format(cached))
    except Exception:
        sys.exit("Error: Unable to update cache from tldr site")

Removing the try/except:

python3.6 /home/user/.local/lib/python3.6/site-packages/tldr.py --download_cache
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.6/site-packages/tldr.py", line 368, in <module>
    main()
  File "/home/user/.local/lib/python3.6/site-packages/tldr.py", line 326, in main
    download_cache()
  File "/home/user/.local/lib/python3.6/site-packages/tldr.py", line 274, in download_cache
    req = urlopen(DOWNLOAD_CACHE_LOCATION)
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 564, in error
    result = self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 756, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

I replaced the call to urlopen with request.get, and I get a 200 instead of the 403, so I'm sure my configuration is not causing this. I'm on Ubuntu 16.04, using Python3.6.

Suggestion:

  • Change the exception for something more accurate. General Exception hide bugs.
  • Put a log so that we can read the exception in a file instead of having to edit the code. Reporting bug would be easier.
  • replace urlopen() with requests.get(), adding requests it to the setup.py "install_requires".

I provided a proof of concept for the quick fix using requests in the following PR.

.tldr_cache prevents any meaningful output

Hi, I just installed tldr via the python client on Xubuntu 16. Apart from serious issues with colours that make the text unreadable on every colour scheme, which I have also seen an issue regarding, I have found that the .tldr_cache directory is causing issues for reading tldr pages.

I am not great at explaining in words, so I will just show a few screenshots.

Let's say I run the command $ tldr nano. Yes, it comes up with the tldr page for nano.

However, now if I were to run the same command a second, third, fourth or even 100th time, I will not get any output anymore. I just get three lines of my console coloured with no text.

image

This is only for tldr pages that I have previously read. If I run tldr with a different page I have not yet read, it is fine.

The fix seems to be to run rm -R ~/.tldr_cache. Once I do this, everything is fine. However, it is annoying to have to keep doing this every single time I want to view a tldr page again.

image

Please excuse the text being unreadable. None of the console colour schemes included with the Xubuntu terminal are any better, and I have other stuff which works well with these console colours, so I wont change my console theme just to get tldr to be readable.

(Sorry if this is a bit vague, this is my first issue on another project).

Thanks

Respect default terminal colours

Hi! I'm a big believer in sane defaults, and the default colour scheme of tldr seems to me anything but.

Would it be possible to use the default background/text/hightlight/... colors from the terminal instead of forcing users to configure it?

Create GH action release workflow

A note to myself, it would be good to create a GH release workflow such that on tagged releases through the GH interface, it would then handle the aspect of pushing the new version to pypi.

Add new owner or maintainer to the pypi project

Hey @felixonmars

This is a follow-up on the email I sent last week. Would you be willing to add a new owner/maintainer to the PyPI project for the tldr-python-client, be it someone from the core organization or just a maintainer for this one (e.g. me or @zdroid). We'd ideally like to look to release 1.0.0, but cannot as it seems you're the only one with access to do that.

In a perfect world, I would want to just hook up an automated pipeline to release onto PyPI for any GH release as well to hopefully help alleviate the need for adding tons of people.

cc'ing @zdroid, @sbrl, @agnivade

tldr tldr shows invalid command examples

Running tldr tldr shows an invalid tldr command:

user@host:~$ ./tldr.py tldr  
# tldr                                                                                                                                                
                                                                     
  Simplified man pages.                                                  
                                                                     
- Get typical usages of a command (hint: this is how you got here!): 
                                                                            
  tldr command                                          
                                                               
- Show the tar tldr page for linux:                      
                                                                      
  tldr -p linux tar                                                  
                                                                   
- Get help for a git subcommand:                                              
                                                                             
  tldr git checkout

Then if the user tries the second example:

tldr -p linux tar

he is greeted with the following:

user@host:~$./tldr.py -p linux tar
usage: tldr.py [-h] [-u] [-o {linux,osx,sunos}] [-s SOURCE] [-c]
               command [command ...]
tldr.py: error: unrecognized arguments: -p

Tested both the python-pip, python3-pip versions on a Debian machine, and by directly cloning the repo, with identical results.

Allow to turn ssl_verify off?

Otherwise this would often fail behind corporate proxies like so:

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)>

Windows: ValueError: need more than 0 values to unpack

Python tldr isn't working for me under Windows 7 native command prompt:

C:\>python --version
Python 2.7.8

C:\>pip install tldr
Collecting tldr
  Downloading tldr-0.1.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): six in c:\python27\lib\site-packages (from tldr)
Requirement already satisfied (use --upgrade to upgrade): termcolor in c:\python27\lib\site-packages (from tldr)
Installing collected packages: tldr
  Running setup.py install for tldr
    Installing tldr-script.py script to C:\Python27\Scripts
    Installing tldr.exe script to C:\Python27\Scripts
Successfully installed tldr-0.1.1

C:\>pip freeze | grep tldr
tldr==0.1.1

C:\>tldr tldr
Traceback (most recent call last):
  File "C:\Python27\Scripts\tldr-script.py", line 9, in <module>
    load_entry_point('tldr==0.1.1', 'console_scripts', 'tldr')()
  File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 521, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2632, in load_entry_point
    return ep.load()
  File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2312, in load
    return self.resolve()
  File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2318, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "C:\Python27\Scripts\tldr.py", line 13, in <module>
    rows, columns = map(int, os.popen('stty size', 'r').read().split())
ValueError: need more than 0 values to unpack

Similarly under Git Bash on Windows 7:

$ python --version
Python 2.7.8

$ pip install tldr
Requirement already satisfied (use --upgrade to upgrade): tldr in c:\python27\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): six in c:\python27\lib\site-packages (from tldr)
Requirement already satisfied (use --upgrade to upgrade): termcolor in c:\python27\lib\site-packages (from tldr)

$ pip freeze | grep tldr
tldr==0.1.1

$ tldr tldr
Traceback (most recent call last):
  File "c:\Python27\Scripts\tldr-script.py", line 9, in <module>
    load_entry_point('tldr==0.1.1', 'console_scripts', 'tldr')()
  File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 521, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2632, in load_entry_point
    return ep.load()
  File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2312, in load
    return self.resolve()
  File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2318, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\Python27\Scripts\tldr.py", line 13, in <module>
    rows, columns = map(int, os.popen('stty size', 'r').read().split())
ValueError: need more than 0 values to unpack

It's working under Linux (Ubuntu virtual machine):

$ python --version
Python 2.7.3
$ pip install tldr
Requirement already satisfied (use --upgrade to upgrade): tldr in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python2.7/dist-packages (from tldr)
Requirement already satisfied (use --upgrade to upgrade): termcolor in /usr/local/lib/python2.7/dist-packages (from tldr
)
Cleaning up...
$ pip freeze | grep tldr
Warning: cannot find svn location for distribute==0.6.24dev-r0
tldr==0.1.1
$ tldr tldr
# tldr



  Simplified man pages



- get typical usages of a command (hint: this is how you got here!)



  tldr {{command}}

Don't drop color when piping

Colorama (by default, appears to be) dropping colors whenever the content is piped (e.g into a pager, as in tldr tar | less -R).

However, if initialized with strip=False, it doesn't do that.

I don't expect tldr to be used to pipe into a file or anything of the sort, while people piping (especially multiple tldrs!) into a pager will likely want their colors.

to reproduce:

  1. install tldr-python-client
  2. run tldr tar | less -R

expected behavior:
less shows colors

actual behavior:
all ansi escape sequences have been stripped

Syntax for listing multiple commands is ambiguous

The python client allows one to specify multiple commands to show their pages at the same time, for example tldr wget curl, which will show you both wget and curl.

Additionally, it allows you to specify a command without specifying its hyphen, for example tldr ansible galaxy is equivalent to tldr ansible-galaxy.

If trying to specify multiple commands, you cannot look at commands that have hyphens and use the above syntax (you must specify the hyphen).

Example: tldr ansible ansible galaxy or tldr ansible galaxy ansible

I'd expect to see the ansible-galaxy page and the ansible page. Instead, it shows the ansible page twice and a warning about how the galaxy page does not exist and I should consider creating one.

It looks like if you wish to use spaces for a command's name, you must use the hyphen. Would it make sense to allow one to always be able to specify the space?


edit (04/23/2020):

For a better example of confusing behavior, typing tldr git grep returns git-grep but did the user mean that or to get back both git and grep separately?

Do not specify default color by default for white text

In the code, tldr defines default colors to use for all attributes:

tldr-python-client/tldr.py

Lines 183 to 190 in c10b95a

DEFAULT_COLORS = {
'blank': 'white',
'name': 'white bold',
'description': 'white',
'example': 'green',
'command': 'red',
'parameter': 'white',
}

As pointed out in #94, these look terrible on non-dark backgrounds as white does not show up well. This is due to the specifying of the white color by default for a number of elements. However, instead of specifying this white default, why not just leave it blank and use the user set text color within their editor? This is probably what the user wants anyway by default and is somewhat guaranteed to look fine for them.

The actual code change here would be to pass None back as the first argument of the tuple from of_colors.

ImportError: No module named cli

Hi, I installed tldr as pip install tldr and pip install tldr.py.
When I used it ,show the errors as follows:

$tldr ssh
Traceback (most recent call last):
File "/usr/bin/tldr", line 7, in
from tldr.cli import cli
ImportError: No module named cli

What shoud I install?

Pages that are only in common, always force an https connection

common vs specific platform

Take for example the command: tldr tldr on linux (Let's assume I already have the file common/tldr.md in my cache directory and it is newer than TLDR_CACHE_MAX_AGE).

One might reasonably assume that no https requests will be made. But in fact, the program first looks for linux/tldr.md, since it's not in the cache, it first requests it from
PAGES_SOURCE_LOCATION/linux/tldr.md
which returns a 404. then after all this, it looks for common/tldr.md and shows the contents.

Solution

I suggest checking the common cache directory before making an https connection for platform specific files. Or to avoid changing default behavior, at least put this behavior behind an option like
--common-before-net

tldr tar shows no output

Any other command I've attempted appears to work as expected, but there may be others failing. Maybe we should change the tests to attempt a wider sample of the pages (or even an exhaustive scan), to capture potential syntax issues?

By the way, three empty lines are added to the output of any command, including tar, not sure why. Probably something to look at as well.

Cannot use most CLI options

Cannot use most of the options (like os or source), due to:

tldr-python-client/tldr.py

Lines 286 to 295 in 06ac37a

options, other_options = parser.parse_known_args()
if options.update_cache:
update_cache(remote=options.source)
return
parser.add_argument(
'command', type=str, nargs='+', help="command to lookup")
options = parser.parse_args(other_options)

line 295 overwrites the option array set on line 286 (which did contain os, source, etc.) and replaces it with the defaults for those options.

Test command:

./tldr -s sunos svcs
`svcs` documentation is not availableConsider contributing Pull Request to https://github.com/tldr-pages/tldr

The namespace before and after the pointed out line:

Before: Namespace(os=['sunos'], source='http://raw.github.com/tldr-pages/tldr/master/pages', update_cache=False)
After: Namespace(command=['svcs'], os=None, source='http://raw.github.com/tldr-pages/tldr/master/pages', update_cache=False)

Drop python2 support

Given that Python2 was deprecated on January 1st, 2020, and its last version was released a few days ago, I would like to propose removing support in this client for python2, and only focus on python3. Python2 is also being phased out increasingly from various Linux distros to be harder and harder to install. Principally, this would just involve:

  • changing the shebang to be #!/usr/bin/env python3 instead of #!/usr/bin/env python
  • remove usage of __future__
  • remove six as dependency

"Documentation is not available." for all commands

I installed this CLI using pacman, and recently it's not finding any documentation for any command.

$ tldr ls
`ls` documentation is not available. Consider contributing Pull Request to https://github.com/tldr-pages/tldr
 $ tldr tar
`tar` documentation is not available. Consider contributing Pull Request to https://github.com/tldr-pages/tldr

How can we fix this?

Bash on Ubuntu on Windows - Internet connection error

Reproduction Rate

I could reproduce the issue each time I tried to print any TLDR page.

Steps to Reproduce

  1. Install Windows Subsystem for Linux.
  2. Install Ubuntu on Windows.
  3. Run Bash on Ubuntu on Windows.
  4. Install linuxbrew. There is installation instruction on http://linuxbrew.sh.
  5. Install Python3: brew update and brew install python3.
  6. Install TLDR Python client: pip3 install tldr.
  7. Try to print any TLDR page.

Result

$ tldr tldr
No internet connection detected. Please reconnect and try again.
$ tldr apt
No internet connection detected. Please reconnect and try again.

Expected Result

TLDR pages

Additional Information

Windows Subsystem for Linux, Bash on Ubuntu on Windows

I have reproduced the issue on AIX 7.1, Python 2.7.12.

[Linux] Cache files in $XDG_CACHE_HOME/tldr instead of ~/.tldr_cache

According to the XDG Base Directory Specification, user-specific cached files files should be stored in $XDG_CACHE_HOME/tldr, or $HOME/.cache/tldr if $XDG_CACHE_HOME is not defined.

There is a single base directory relative to which user-specific non-essential (cached) data should be written. This directory is defined by the environment variable $XDG_CACHE_HOME.

This avoids cluttering the home directory and simplifies including/excluding related directories from bulk operations such as backups.

Links

Repos

tldr package in Fedora

Hello.

tldr will be available as a package for Fedora Linux soon. Could I add it as an option for installation? Just asking before creating PR.

Thanks and have a nice day.

Reduce empty lines in output

Current python-client has 2 empty lines at the beginning of output, 3 empty lines at the end of the output.

How about reduce both empty line to 1 empty line (1 at the beginning, 1 at the end)? Because those extra empty lines look unnecessary/not practical when we use tldr in the terminal.

Though I agree the current version's screenshot in README.md looks beautiful, but it's not that beautiful in the terminal. (Of course we can still use that screenshot, but change this behavior in actual use).

support offline pages

As of now, all tldr pages are ~370KB. Instead of being saved all at once, they are cached for each command when the client runs and it doesn't use the same folder structure as tldr (common, linux, etc), but adds a suffix for each one (e.g. awk_common.md).

Grey color instead of white

I tried to set the output of tldr to white but it shows a grey color instead.

Default:
Selection_001

export TLDR_COLOR_EXAMPLE="white"
Selection_002

I bet it's a problem related to my system (not a bug), I'm just wondering what's the cause.

Cache file could be better documented in the readme file

It might be a good idea to briefly mention in the readme file something about what's going on with the cache file; that it's an automated process: data is pulled from the tldr repo, zipped, commited to the tldr webpage repo, downloaded to the client and then unzipped.

I think it should be more clear to the user what's the source of the data the client downloads. I had to look at the source of this python client, at the tldr website repo, at this code and then at this other script to figure where's the file coming from.

Cache saving empty file and then displaying empty pages

First of all my environment:
Kubuntu 17.04
python3.6
None of the env variables in the man is set.

Installing the client and running it for the first time fetches the pages correctly and creates s $HOME/.tldr_cache page with the cached command. However the saved file is empty and running the tldr command again with the same parameter yields an empty response.
tldr -u says it is updating cache but does not seem to work.

Workaround for this is to delete the $HOME/.tldr_cache folder

Oh and by the way it does not seem to take into consideration env variables at all. Whether they are in ~/.bashrc; /etc/environment or other similar place, not taken into consideration.

tldr "documentation is not available"

tldr {command}
outputs
"{command}" documentation is not available. Consider contributing Pull Request to https://github.com/tldr-pages/tldr
given any command.
ping github.com works, tldr -u outputs "Updated cache for 0 entries"

Fix handling for pt_BR and pt_PT

While most languages only use the ll bit of the ll_CC language specification, Portuguese is split using the full code to differentiate between Brazilian and Portugal Portuguese, which is currently not supported by the client.

New collaborators

Continues the tradition of #55. (@waldyrious if you think any of the previous names should still be on the list, just add them here)

An organization member should invite the following people to be repository collaborattors, as they qualify for the repository collaborator status:

Add new collaborators to the repo

Following tldr-pages/tldr#1878, I'm inviting all contributors to this repo that meet the criteria specified in tldr-pages/tldr#1839 for being added as collaborators. They are:

Welcome aboard!

Note: all contributors above were invited with write permissions. @felixonmars, as the creator and main author of this repo, retains admin permissions.

This issue will remain open until the invitations are either accepted or declined.

Add changelog

Subj. It would be clearly to see list of changes according to version numbers. It may be simply a digest of commit messages for each version.

Change background color formatting

The current background color formatting can clash with different terminal emulator color profiles. For example, see the output in this image, which is a screenshot from my terminal (Fedora 27, default emulator, monokai dark color profile).
https://i.imgur.com/EuJTEXL.png
If possible, don't specify a background color, or use general codes which override a user's color profile for a consistent look an all platforms.

ImportError: No module named urllib.parse

Hi,

I just installed your tldr client with sudo pip install tldr. This is what happens when I run it:

foo@bar ~ $ tldr ssh
Traceback (most recent call last):
  File "/usr/local/bin/tldr", line 9, in <module>
    load_entry_point('tldr==0.1.1', 'console_scripts', 'tldr')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 343, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2309, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2015, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/bin/tldr.py", line 7, in <module>
    from six.moves.urllib.parse import quote
ImportError: No module named urllib.parse

Kind regards,
Arne

tldr displays traceback on ctrl-c

When one hits ctrl-c during execution of tldr command it displays a traceback caused by KeyboardInterrupt. We should consider catching that exception.

Add ability to omit background color option

Now we can't specify font as dark (or bold, underline, blink, reverse, concealed) without changing background color. Meanwhile we can't specify background color to black (due to termcolor library limitations).

DEFAULT_COLORS = {
    'command': 'red on_grey dark',
    'parameter': 'green dark',
}

In [11]: colors_of('command')
Out[11]: ('red', 'on_grey', ['dark'])  # Correct!

In [12]: colors_of('parameter')
Out[12]: ('green', 'dark', [])  # Not correct!

So I think we should to improve colors_of method.

Parameters in command line are not parsed and not painted

What I expect to see (picture from tldr main page)
tldr-expectations

What I actually see
bwh1te bwh1te-peka _005

As we can see on this screenshot, param pattern {{user_param}} is not parsing by python client. Since it doesn't parse, it can't be painted like it does on first pic.

What we should do:

  1. Add new DEFAULT_COLORS entry (parameter for example)
  2. Parse command lines for {{param}} patterns and paint in parameter color
  3. Another parts of the line should be painted in command color
  4. Except the first two spaces (as we can see on first pic)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.