For now? A touch of getopts.
When writing scripts for command line use, the getopt parser is a useful little module.
from optparse import OptionParser parser = OptionParser() parser.add_option("-t", "--test", dest="testvalue", help="the test value that will be printed.") (options, args) = parser.parse_args() print parser.values.testvalue
This is the simplest possible program you can use getopt for - here you can see how the opt parser will collect its data and store it. By grabbing known options and args. The best part is, if you set it up correctly, you can get help files automatically generated. Add a help option, and you can just create a simple script to scroll through optparse options, and their descriptions, to generate a nice list of help files.
Now, if you excuse me, I literally feel my knee about to throw out, and I'm tired and have work early tomorrow morning. So good night, readers. Sorry for the morsel size code entry today - couldn't be helped.
No comments:
Post a Comment