What is python alternative to thor (ruby) for command line applications?

command-line-arguments, command-line-interface, python, thor

Solution

Python offers natively (via standard library) two packages to create auto-documenting interfaces for command line tools: optparse and argparse.

The docs says that `optparse` is deprecated and `argparse` replaces it, maintaining some backward compatibility where possible. Though, argparse is not so easy to use and 3rd-party libraries have been created.

Have a look at docopt and the video about it. cliff is another possibility.

To write line-oriented command interpreters you can find useful the Python cmd module.

I finally want to point out that docopt and cliff are not the Python alternative/s as you asked, but just the couple I found.

Problem

What is the python alternative to Thor for building self-documenting command line utilities? UPDATE: The click is the closest equivalent of Thor for python, see http://click.pocoo.org/

Original source