TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Click – Python library for command-line interfaces

370 pointsby gregnavisabout 11 years ago

28 comments

the_mitsuhikoabout 11 years ago
I 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.
评论 #7641250 未加载
评论 #7643436 未加载
评论 #7640254 未加载
评论 #7642895 未加载
hoodoofabout 11 years ago
Gorgeous. 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.
评论 #7640106 未加载
评论 #7639916 未加载
评论 #7639751 未加载
评论 #7640429 未加载
tudborgabout 11 years ago
It looks really well done.<p>I still prefer docopt (<a href="https://github.com/docopt/docopt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;docopt&#x2F;docopt</a>) . It is so much simpler to use. Click seems to be a bit overengineered.
评论 #7639508 未加载
评论 #7639764 未加载
评论 #7639614 未加载
评论 #7639654 未加载
sotteabout 11 years ago
Does anybody know docopt? I really like it because you simply write the help&#x2F;usage as text and docopt automatically generates the parser for it.<p>Take a look at the example in the README: <a href="https://github.com/docopt/docopt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;docopt&#x2F;docopt</a>
评论 #7639580 未加载
clarkevansabout 11 years ago
It seems to me that there are a few projects similar this. Here is another, <a href="https://pypi.python.org/pypi/Cogs/" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;Cogs&#x2F;</a> (conceptualized as a &quot;Makefile&quot; replacement).<p>I&#x27;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?
评论 #7640176 未加载
pandatigoxabout 11 years ago
Kudos again to the pocoo team for creating such a simple and useful library. It sure beats optparse :)<p>On a side note, however, does anyone know why the team prefers to wrap functions in decorators? Flask also uses them, but what&#x27;s the design decision behind them?
评论 #7639397 未加载
评论 #7639952 未加载
peterjsabout 11 years ago
On a related note. Which python library would you recommend for text-based interfaces? I have never used ncurses, so I don&#x27;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.
评论 #7639828 未加载
评论 #7642450 未加载
评论 #7646119 未加载
bruabout 11 years ago
&gt;You can get the library directly from PyPI:<p>&gt;pip install click<p>Well... no you cannot. See the page: <a href="https://pypi.python.org/pypi/click" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;click</a><p>The package hasn&#x27;t been uploaded yet. However one can install it straight from the git repo:<p>&gt; pip install git+ssh:&#x2F;&#x2F;git@github.com:mitsuhiko&#x2F;click.git
评论 #7640088 未加载
评论 #7640119 未加载
xiaqabout 11 years ago
A bit off-topic, but I like how pocoo.org uses different fonts for different projects:<p>Flask: Georgia for text, Garamond for titles<p>Werkzeug: Lucida Grande for text, Ubuntu for titles<p>And now click: Ubuntu Mono for text, Open Sans for titles
评论 #7644366 未加载
erlkonigabout 11 years ago
Why is it that (nearly) every description I read about some random new Python command wrapper fails to get the &quot;python&quot; and &quot;.py&quot; out of the command examples, even in Linux?<p>I don&#x27;t blame this particular offering, since I don&#x27;t think release was actually planned just yet and any number of other projects have made the same subtle mistake.<p>Command Name Extensions are Harmful. Don&#x27;t expose such an implementation detail in every example, lest everyone actually follow them. Use the &quot;#!&#x2F;usr&#x2F;bin&#x2F;env python&quot; or whatever at the top of your scripts. And yes, you can keep the .py if what you have is a library, not just a command (but it&#x27;s nice to then make a wrapper the doesn&#x27;t expose the implementation language). And obviously in other OSes where the command extension can be omitted and still work this isn&#x27;t such a big deal.<p>But in Unix&#x2F;Linux, commands should be reimplementable in a different language without making some .(extension) a like, retained to keep from breaking other things that depend on it. Just say no :-)
评论 #7642894 未加载
mahmoudimusabout 11 years ago
I should write up a comparison between:<p>- Cement (<a href="http://builtoncement.com" rel="nofollow">http:&#x2F;&#x2F;builtoncement.com</a>)<p>- Cliff (<a href="http://cliff.readthedocs.org/en/latest/" rel="nofollow">http:&#x2F;&#x2F;cliff.readthedocs.org&#x2F;en&#x2F;latest&#x2F;</a>)<p>- Plumbum (<a href="http://plumbum.readthedocs.org" rel="nofollow">http:&#x2F;&#x2F;plumbum.readthedocs.org</a>)<p>- Argh (<a href="https://pypi.python.org/pypi/argh/0.24.1" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;argh&#x2F;0.24.1</a>)<p>- Aaargh (<a href="https://github.com/wbolster/aaargh" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wbolster&#x2F;aaargh</a>)<p>- Baker (<a href="https://pypi.python.org/pypi/Baker/" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;Baker&#x2F;</a>)<p>So many more to choose from. Now we get to evaluate Click. Seems like the reason Armin wrote Click was to load options dynamically, but that&#x27;s what Cliff does via stevedore (<a href="https://github.com/dreamhost/stevedore" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dreamhost&#x2F;stevedore</a>).<p>My favorite feature about Cliff though is: <a href="http://cliff.readthedocs.org/en/latest/complete.html" rel="nofollow">http:&#x2F;&#x2F;cliff.readthedocs.org&#x2F;en&#x2F;latest&#x2F;complete.html</a> which comes out of the box, but then again, there&#x27;s Argcomplete (<a href="https://github.com/kislyuk/argcomplete" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kislyuk&#x2F;argcomplete</a>).<p>EDIT: Updating from previous posters<p>- Naked (<a href="http://naked-py.com" rel="nofollow">http:&#x2F;&#x2F;naked-py.com</a>)<p>- Docopt (<a href="http://docopt.org" rel="nofollow">http:&#x2F;&#x2F;docopt.org</a>)<p>- Clint (<a href="https://github.com/kennethreitz/clint" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kennethreitz&#x2F;clint</a>)<p>- Argvard (<a href="https://github.com/DasIch/argvard" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DasIch&#x2F;argvard</a>)<p>- Commandr (<a href="https://github.com/tellapart/commandr" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tellapart&#x2F;commandr</a>)<p>- Argtools (<a href="https://pypi.python.org/pypi/argtools/0.1.2" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;argtools&#x2F;0.1.2</a>)<p>- Plac (<a href="https://pypi.python.org/pypi/plac" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;plac</a>)
评论 #7645004 未加载
评论 #7657402 未加载
评论 #7646268 未加载
lorenzfxabout 11 years ago
This looks pretty similar to aargvard [1] (which is, as stated in the README, inspired by flask).<p>[1] <a href="https://github.com/DasIch/argvard" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DasIch&#x2F;argvard</a>
edddabout 11 years ago
<a href="https://readthedocs.org/projects/argh/" rel="nofollow">https:&#x2F;&#x2F;readthedocs.org&#x2F;projects&#x2F;argh&#x2F;</a>
评论 #7639900 未加载
thuabout 11 years ago
The 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 doing in just a few days and so I add a lot of small commands).<p>In short running `foo --help` should be instant and if it loads all its modules to list the different sub-commands and their respective description it is really too slow.<p>A possibility is to cache some information (e.g. generate a text file or a small Python script).
评论 #7639742 未加载
评论 #7639864 未加载
评论 #7640033 未加载
nubelaabout 11 years ago
Ahh.. I really like pocoo&#x27;s products. But I&#x27;ve found manage.py (<a href="https://github.com/Birdback/manage.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Birdback&#x2F;manage.py</a>) to be far leaner and simple. What do you guys think?
评论 #7639790 未加载
jobeirneabout 11 years ago
This doesn&#x27;t look much different than argh, which has been around for ages: <a href="http://argh.readthedocs.org/en/latest/tutorial.html" rel="nofollow">http:&#x2F;&#x2F;argh.readthedocs.org&#x2F;en&#x2F;latest&#x2F;tutorial.html</a>
busterabout 11 years ago
Looks nice but the example looks almost exactly like <a href="https://pypi.python.org/pypi/argtools/0.1.2" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;argtools&#x2F;0.1.2</a>
gdw2about 11 years ago
Reminds me of Commandr. Both use decorators. <a href="https://github.com/tellapart/commandr" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tellapart&#x2F;commandr</a>
moondownerabout 11 years ago
Little unfortunate naming. Isn&#x27;t Click a trademark of ASF? <a href="http://click.apache.org/" rel="nofollow">http:&#x2F;&#x2F;click.apache.org&#x2F;</a>
评论 #7640948 未加载
eeadcabout 11 years ago
Looks like a nice wrapper around argparse: <a href="https://docs.python.org/3/library/argparse.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;argparse.html</a>
评论 #7639489 未加载
kylemaxwellabout 11 years ago
Trying to figure out how this compares to Naked (<a href="http://naked-py.com" rel="nofollow">http:&#x2F;&#x2F;naked-py.com</a>) in terms of goals.
waitingkuoabout 11 years ago
Time to rewrite some of my dirty command-line programs
Spiritusabout 11 years ago
<a href="https://github.com/mitsuhiko/click" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mitsuhiko&#x2F;click</a>
frodopwnsabout 11 years ago
user@uweb1:&#x2F;$ pip install click Downloading&#x2F;unpacking click Could not find any downloads that satisfy the requirement click No distributions at all found for click
_ZeD_about 11 years ago
do you know plac[0]?<p>[0] <a href="https://pypi.python.org/pypi/plac" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;plac</a>
pekkabout 11 years ago
There are like 20 libraries for this already and this looks very similar to those. But Armin Ronacher, therefore it will be popular
gr3yh47about 11 years ago
the name is a bit oxymoronic
tiziano88about 11 years ago
is there anything like this for Go?
评论 #7640031 未加载