Message121250
Trying to spec this, here is a proposed API:
parser = argparse.ArgumentParser()
sub = parser.add_subparsers(default='show')
sub_show = sub.add_parser('show')
sub_add = sub.add_parser('add')
If default isn't passed, the subcommand isn't optional.
If default is passed, and no explicit subcommand is given,
the default subcommand is picked.
Arguments are given to the top parser; passing arguments
to the subcommand requires naming it explicitly.
As far as motivation, I'd like to change a program that
uses --choice options (that can have a default) to use
more expressive subcommands. Some programs rely on implicit
subcommands a lot; the ip command on linux is a good
example. |
|
| Date |
User |
Action |
Args |
| 2010-11-15 23:23:51 | G2P | set | recipients:
+ G2P, bethard, eric.araujo, r.david.murray, nvie, elsdoerfer |
| 2010-11-15 23:23:51 | G2P | set | messageid: <[email protected]> |
| 2010-11-15 23:23:49 | G2P | link | issue9253 messages |
| 2010-11-15 23:23:49 | G2P | create | |
|