>You can get the library directly from PyPI: >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
Click – Python library for command-line interfaces
51–60 of 105 posts
Re: Click – Python library for command-line interfaces
#52On 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.
I'd say http://urwid.org/ should be the best choice for something like that. The main alternative would be to hack it together by yourself using https://docs.python.org/3.4/library/curses.html
Re: Click – Python library for command-line interfaces
#53Earlier quoted context omitted.
> The biggest gripe I have with using Python for rich command-line tool is the startup time. 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.
I just tried on an app at work (Django app): > time python manage.py --help real 0m0.473s user 0m0.240s sys 0m0.148s Half of a second is very noticeable (and annoying). I had similar perception in my previous work. You can try to only load enough to display the help text without really loading everything, but that doesn't work that well (you have to organize things differently, and `--help` requires to load a lot of…
Re: Click – Python library for command-line interfaces
#54>You can get the library directly from PyPI: >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
> pip install git+ssh://git@github.com:mitsuhiko/click.git Can someone comment regarding using pip like that? Is it fine to put this on req.txt? Any best practices somewhere?
If you plan to release your stuff, the dependencies in your req.txt should be as pinned as possible. The classic example is Requests: when it changed the API fairly significantly, umpteen installers broke... just because people did not bother with specifying a version for that lib.
Re: Click – Python library for command-line interfaces
#55Earlier quoted context omitted.
It's a wrapper around optparse, as per http://click.pocoo.org/why/ . I'm curious about that decision given that optparse is deprecated. It says it's because argparse doesn't allow nested commands, but I don't really see why that feature is so desirable as to warrant using a deprecated module. I probably need to have a play with it to find out. Looks like a nice module.
Click can be extended lazily which helps execution time a lot when working with many, many plugins. It also can be extended at runtime as per configuraton. argparse requires the parser to have full knowledge of everything which makes it slow if you add many commands. Biggest problem though is that it's parsing system is a bit broken when it comes to escaping. Options with arguments cannot have values starting with da…
Re: Click – Python library for command-line interfaces
#56Re: Click – Python library for command-line interfaces
#57It seems to me that there are a few projects similar this. Here is another, https://pypi.python.org/pypi/Cogs/ (conceptualized as a "Makefile" replacement). I'm wondering if there could be a breakout at the next PyCon to see if we could discuss approaches and come up with a unified way to do convert Python libraries into command line scripts?
- Cliff http://cliff.readthedocs.org/en/latest/
- docopt http://docopt.org
- argparse
- optparse
etc etc etc...
Re: Click – Python library for command-line interfaces
#58I did not expect this to be on hackernews this early. I want to point out that I have not made a release yet and it's not yet feature complete. Mainly I want to ask for feedback on the general design.
https://github.com/seaneagan/unscripted
Checkout the github issues there for some features I want to add, like bash completion support for example. I think we can steal ideas from each other!
One nice thing about dart's annotations vs. python's decorators is they can be placed on a function's parameters as well, so it allows the option/flag/argument declarations to be a bit more DRY.
Re: Click – Python library for command-line interfaces
#59>You can get the library directly from PyPI: >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
> pip install git+ssh://git@github.com:mitsuhiko/click.git Can someone comment regarding using pip like that? Is it fine to put this on req.txt? Any best practices somewhere?
pip install "https://github.com/mitsuhiko/click/tarball/master#egg=click"
to pin a specific revision:
pip install "https://github.com/mitsuhiko/click/tarball/5b7b7296fabc5d47d...
(btw, it seems bad practice to add such a link as a dependency in your setup.py... usually you'd do it for temporary shallow forks, but otherwise I think it'd be better to also upload your shallow fork on pypi ...I guess you can just remove it from pypi if it won't be needed anymore)
Re: Click – Python library for command-line interfaces
#60Earlier quoted context omitted.
Click can be extended lazily which helps execution time a lot when working with many, many plugins. It also can be extended at runtime as per configuraton. argparse requires the parser to have full knowledge of everything which makes it slow if you add many commands. Biggest problem though is that it's parsing system is a bit broken when it comes to escaping. Options with arguments cannot have values starting with da…
Can you provide an example of what you're saying? I've found that argparse.ArgumentParser.parse_known_args() and sub-parsers can do everything I can see click doing. Including lazy loading of plugins and the like.
Links to some open bugs on it:
* http://bugs.python.org/issue13966
* http://bugs.python.org/issue14191