Live data from Hacker News

Easy Python CLI with Click

codingwithricky.com

61–64 of 64 posts

Re: Easy Python CLI with Click

#61

Earlier quoted context omitted.

It's easy to make self-contained scripts with dependencies using Pex: https://github.com/pantsbuild/pex/

I don't think it makes sense to bundle multiple python interpreters into a 100MB executable so that my ftp_send.py script can parse command line arguments

Pex doesn't bundle any interpreters.

Re: Easy Python CLI with Click

#63
post #9

I'm not sure why click is often recommended. I've used argh for years and find it easier: def hello(name): return "hello {}".format(name) def ping(): return "pong" if __name__ == "__main__": import argh parser = argh.ArghParser() parser.add_commands([hello, ping]) parser.dispatch()

Yep, this is my first time seeing Click and it looks very similar to argh.

Personally I'll probably stick to argh, but good to see some competition in the space.

One nice thing about argh is that it's mostly just a fancy wrapper around argparse. So you have the full functionality of argparse if you need it, while still getting the lack of boilerplate and nice defaults of argh.

It also means it works with other third party things on top of argparse like argcomplete for tab completion.

Does anyone know if Click is similar, or if it implements its own parser?

EDIT: Answered my own question. Looks like it uses optparse internally. So yeah, should see similar benefits.

Re: Easy Python CLI with Click

#64
post #58

Click unfortunately doesn't pass the smell test of a non-awkward implementation of 'sudo'. It gets some partial credit because an implementation is possible but only because you can subclass the click.Command object and change the parsing behavior arbitrarily. So many of these parsing libraries seem to forget that any positional parameter can stop options parsing not just '--' and that that parameter might appear arb…

Which Python library fills this requirement well?
Post reply on HN