views:

86

answers:

4

I want to create a set of command-line utilities in python that would be used like so:

python utility.py command1 -option arg

Very similar to django management commands. Is there any library that eases the creation of such commands?

+2  A: 

Optparse is the way to go

bassfriend
+1  A: 

Take a look at plac. I haven't used it as I stumbled to it just recently. It looks simple enough, though.

bebraw
+5  A: 

Baker is rather nice I think. Optfunc maybe also.

Steven
+1 for baker. I love decorators.
mawimawi
Baker looks nice
bassfriend
Thanks for suggesting Baker.
Vasil
+3  A: 

You just want to create a two-level command? You should use argparse -- it's simple enough, is similar to optparse but makes the two-level command thing easy, and will be in the standard library with Python 2.7.

Ian Bicking