|
|
|
|
|
by mey
2167 days ago
|
|
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-v','--version',action='version', version='demo',help='Print version information')
parser.add_argument('-d','--debug', help='Enable Debug Mode')
parser.add_argument('a','arg', help="Argument Documentation")
args = parser.parse_args()
Personally I feel like this is more readable code, gets me better validation, and help docs for "free". That's the attraction. |
|
If you can live with additional dependencies, then I like the node [1] commander package, which is very readable and nice to work with in my opinion.
It also automatically generates the --help output for ./script -h[1] https://github.com/tj/commander.js/