tldr-pages / tldr-python-client Goto Github PK
View Code? Open in Web Editor NEWPython command-line client for tldr pages
Home Page: https://pypi.org/project/tldr/
License: MIT License
Python command-line client for tldr pages
Home Page: https://pypi.org/project/tldr/
License: MIT License
Keep getting this error on OSX high sierra on command prompt. The session has internet connectivity and i'm able to get to it.
Any help will be appreciated. Thanks.
-m
The current version on PyPI, v0.3, has a bunch of bugs that have been fixed in the master version, such as #31 and #32.
I can make a new release on github, but I can't update the PyPI package, as only @felixonmars has access. So this issue is two-fold:
make a new release here and on PyPI
add some people as owners/maintainers in PyPI (example)
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')
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
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.
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:
tldr tar | less -R
expected behavior:
less shows colors
actual behavior:
all ansi escape sequences have been stripped
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.
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?
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:
#!/usr/bin/env python3
instead of #!/usr/bin/env python
__future__
six
as dependencyThe 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?
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.
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:
I provided a proof of concept for the quick fix using requests in the following PR.
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.
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
).
In the mac tldr client if you type tldr git pull
you get the equivalent of tldr git-pull
Is there a way to set this up on the python version as well?
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.
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
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.
What I expect to see (picture from tldr main page)
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:
DEFAULT_COLORS
entry (parameter
for example)command
lines for {{param}}
patterns and paint in parameter
colorcommand
colorRunning 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.
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.
to fetch corresponding page from remote repository every time is very slow.
Hi!
Is it possible to run private pages? I cannot find this option.
Auto completion for the cli options and available pages would be nice.
Something along the lines of the zsh and bash completions here: https://github.com/tldr-pages/tldr-node-client/tree/master/bin
This client currently does not have an option to list all available pages it seems, which would be a requirement.
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)>
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.
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.
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.
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
Run the following:
tldr foo; echo $?
0 will be printed out, despite foo not having a tldr entry. Relates to letompouce tldr-pages/tldr#4227
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:
I waited way too long for my tldr nmap
page to display. TLDR should IMHO be caching the pages it uses - perhaps all of them.
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?
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.
If add -H or --host option, we can get help from localhost. Also we can add md help at localhost :)
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}}
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.
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.
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.
In the code, tldr defines default colors to use for all attributes:
Lines 183 to 190 in c10b95a
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
.
Currently it's changing the background color to blue (like in the screenshot in https://github.com/tldr-pages/tldr); that's unnecessary and the result isn't exactly pretty.
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"
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.
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.
I could reproduce the issue each time I tried to print any TLDR
page.
linuxbrew
. There is installation instruction on http://linuxbrew.sh
.Python3
: brew update
and brew install python3
.TLDR
Python
client: pip3 install tldr
.TLDR
page.$ tldr tldr
No internet connection detected. Please reconnect and try again.
$ tldr apt
No internet connection detected. Please reconnect and try again.
TLDR
pages
Windows Subsystem for Linux, Bash on Ubuntu on Windows
I have reproduced the issue on AIX 7.1
, Python 2.7.12
.
Cannot use most of the options (like os or source), due to:
Lines 286 to 295 in 06ac37a
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)
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
When one hits ctrl-c
during execution of tldr
command it displays a traceback caused by KeyboardInterrupt
. We should consider catching that exception.
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?
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).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.