Hacker News new | ask | show | jobs
by garmaine 2533 days ago
At first I thought this was a parser to automatically convert help text for a command into an argument parser. Something I didn’t realize I needed until right now. Someone write that thing too!
1 comments

http://docopt.org/ — turns help text in a Python doc string into an argument parser.

After a doc string put:

    import docopt
    args = docopt.docopt(__doc__, version='0.0.1')
Edit: krapht points out there is now support for multiple languages: https://github.com/docopt
I use Docopt now for every CLI script I write, using Docopt language ports. Skipping argument parsing boilerplate is so nice, not to mention now I don't have to remember how each different language is supposed to idiomatically parse CLI arguments.