def parseOptions(args):
config = {}
# Command line flags - default values
config['args'] = []
# Read in and process the command line flags
try:
opts, args = getopt.getopt(args, "h", ["help",])
except getopt.GetoptError, err:
# Print help information and exit:
print str(err) # will print something like "option -a not recognized"
usage(exitCode=2)
# Work through opts
for opt, value in opts:
if opt in ('-h', '--help'):
usage(exitCode=0)
else:
assert False
# Add in arguments
config['args'] = args
# Return configuration
return config
评论列表
文章目录