There once was getopt library, but it was awkward compared to newer optparse module, but even optparse nowadays is not enough for some who is willing to replace it with argparse. optparse is a kind of "stable minimal API" that is not easy to push a change to. As a person who has a lot of Python command tools at hand I often feel that I need patched version of optparse, but I can't afford managing dependencies or inserting a bulk of code into 5 minute script that should be as minimal and clear as possible for easy maintenance. So I wouldn't mind against more featured argparse library.
However, argparse can only be useful in standard library if it will be:
- Minimalistic. Like optparse won't take much brainspace to avoid referencing documentation for 80% of the stuff
- Easily extensible
- Contains copy/paste recipes for popular usages
Is it easily extensible? It allows to specify formatter class, conflict_handler class, but it seems like you have very limited control over what will be matched as option and what as an argument. There are two options to constructor to define options prefix - prefix_chars and fromfile_prefix_chars, but they are awkward. I wonder if I can provide /longarg on windows in addition to --longarg leaving also /s and -s options? It could be better done with the same custom class, which could be provided in recipes or as an optional import.
There are no recipes in argparse. That's bad, because that means the library is designed as a comprehensive solution to all command-line problems, but it still can't help me make the majority of my scripts more convenient without too much overhead.
argparse is not a huge leap from optparse as the latter once was for getopt in my opinion. For any argument parsing library to become a quality leap from optparse, it should allow an easy way to build svn like command line interfaces with the following features:
- calling without arguments shows tool name, version and usage info
- usage info contains either command list, options list or both
- "tool.py help
" is equivalent to "tool.py -h" - remove ugly default optparse help for options with arguments
-f FILE, --file=FILE write report to FILE
SVN is fine
-r [--revision] ARG : ARG (some commands also take ARG1:ARG2 range)
or Mercurial
-l --logfile read commit message from
- cross-platform optional paging