Is there a Python module for doing gem/git-style command line arguments? What I mean by gem/git style is:
$ ./MyApp.py
The most commonly used MyApp commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
...
$ ./MyApp.py branch
* current-branch
master
With no arguments, the output tells you how you can proceed. And there is a special “help” command:
$ ./MyApp.py help branch
Which gets you deeper tips about the “branch” command.
Edit:
And by doing I mean it does the usage printing for you, exits with invalid input, runs your functions according to your CLI specification. Sort of a “URL mapper” for the command line.
Yes,
argparsewithadd_subparsers().It’s all well explained in the Sub-commands section.
Copying one of the examples from there:
Edit: Unfortunately there’s no self generated special
helpcommand, but you can get the verbose help message (that you seem to want) with-hor--helplike one normally would after the command:By verbose I don’t mean that is like a man page, it’s like every other
--helpkind of help: listing all the arguments, etc…Example:
If you need to, it should be easy to implement an
helpcommand that redirects to--help.