[ANN] main.py
Well, all I can say is that I hope I’m not treading on anyone else’s namespace with my little effort.
I finally got bored with rolling and re-rolling my own command line processors in Python, so I’ve knocked together a little something to make things simpler for myself.
It’s loosely based on the marvellously prolific Ara T. Howard’s main gem, but it doesn’t have nearly the feature set. Yet. I guess I’ve given myself something to aim for there.
Anyhow, here’s how to use it, nicked straight from the README:
import main
import sys
def callback(params):
print "Called with " + params['foo'].value
m = main.mode("run", callback)
m.option("foo")
m.description="How not to be seen"
main.process(sys.argv)
Called as:
$ python b.py
Outputs:
Usage:
# How not to be seen
b.py run --foo=<foo>
Called as:
$ python b.py run --foo=bar
Outputs:
Called with bar
There’s lots left to do (decent error handling, for instance – it makes a modicum of effort, but largely you can expect mistakes to blow up in your face), but it’s a start.