On a related note. Which python library would you recommend for text-based interfaces? I have never used ncurses, so I don't know how complex it is. What I would like to achieve is having a user launch my script from the command line, use the text based interface to select a source and destination folder, set a few parameters and show a progress bar.
Click – Python library for command-line interfaces
31–40 of 105 posts
Re: Click – Python library for command-line interfaces
#32Re: Click – Python library for command-line interfaces
#33>pip install click
Well... no you cannot. See the page: https://pypi.python.org/pypi/click
The package hasn't been uploaded yet. However one can install it straight from the git repo:
> pip install git+ssh://git@github.com:mitsuhiko/click.git
Re: Click – Python library for command-line interfaces
#34The biggest gripe I have with using Python for rich command-line tool is the startup time. One of the first reason I like to write a nice command-line tool when I start a project, say foo, is to be able to do `foo --help` to quickly see and remember what the project can do (I have a very bad memory and doing this makes it possible for me to jump back faster to a project, even well documented. I can forget what I was…
What startup time?
I even have a python script running on every shell prompt drawing (that checks mercurial on top of starting the python interpreter), and the latency is negligible.
Re: Click – Python library for command-line interfaces
#35Re: Click – Python library for command-line interfaces
#36It looks really well done. I still prefer docopt ( https://github.com/docopt/docopt ) . It is so much simpler to use. Click seems to be a bit overengineered.
If you need to parse something as simple as `foo --option spam --option eggs` remembering both spam and eggs, docopt breaks down. You are also unable to compose an interface using docopt, if you want to allow plugins in a plugin system to add their own options for example. docopt is much simpler because it's only capable of creating very trivial interfaces. That's perfectly fine if that's all what you want to do but…
Usage:
script.py --option=...
script.py --option spam --option eggs
{
"--option": [
"spam",
"eggs"
]
}
Example here [0].I haven't pushed it too far so I'm sure there are other cases where you'd need to create a different command line api to have it work (that may or may not be an issue depending on your use case).
Regarding the other criticism, seems valid. In the docopt api can you have it do the parsing for you so you can edit the rules afterwards before you run them?
[0] http://try.docopt.org/?doc=Usage%3A%0D%0A++script.py+--optio...
Re: Click – Python library for command-line interfaces
#37Re: Click – Python library for command-line interfaces
#38https://readthedocs.org/projects/argh/
Re: Click – Python library for command-line interfaces
#39Re: Click – Python library for command-line interfaces
#40Gorgeous. This guy has a full time job, a wife, and wrote Flask and Werkzeug, ItsDangerous, Sphinx, Markupsafe, Jinja2 (and Jinja) and that's just some of the well known stuff. Handsome and young too. Bastard. He probably saves the world in a dinner jacket in his spare time.