Issue 54 in argparse: When using subcommands, option in parent parser should be placeable anywhere

63 views
Skip to first unread message

argp...@googlecode.com

unread,
Jan 6, 2010, 7:08:32 PM1/6/10
to argpar...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 54 by ianbicking: When using subcommands, option in parent parser
should be placeable anywhere
http://code.google.com/p/argparse/issues/detail?id=54

I have a command with a bunch of subcommands. In the parent parser I added
a verbose option. I can do:

mycommand --verbose subcommand --something

But I expect to also be able to do this:

mycommand subcommand --verbose --something

But... I can't.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

argp...@googlecode.com

unread,
Jan 7, 2010, 12:37:36 PM1/7/10
to argpar...@googlegroups.com

Comment #1 on issue 54 by steven.bethard: When using subcommands, option in
parent parser should be placeable anywhere
http://code.google.com/p/argparse/issues/detail?id=54

That's intentional because it's possible you might want those two --verbose
flags to
mean different things. If you want them to mean the same things, I'd
suggest using a
parent parser:

verbose_parser = argparse.ArgumentParser(add_help=False)
verbose_parser.add_argument('--verbose', action='store_true')

parser = argparse.ArgumentParser(parents=[verbose_parser])
subparsers = parser.add_subparsers()
foo_parser = subparsers.add_parser('foo', parents=[verbose_parser])

That should allow the same --verbose flag to be specified in either parser.

argp...@googlecode.com

unread,
Feb 28, 2010, 5:08:30 AM2/28/10
to argpar...@googlegroups.com
Updates:
Status: WontFix

Comment #2 on issue 54 by steven.bethard: When using subcommands, option in

parent parser should be placeable anywhere
http://code.google.com/p/argparse/issues/detail?id=54

(No comment was entered for this change.)

argp...@googlecode.com

unread,
Aug 21, 2015, 9:49:14 AM8/21/15
to argpar...@googlegroups.com

Comment #3 on issue 54 by stewart....@gmail.com: When using subcommands,
option in parent parser should be placeable anywhere
https://code.google.com/p/argparse/issues/detail?id=54

Should this work with sub-parsers? I am not seeing the parents option as a
valid option to either .add_subparsers() or .add_parser().

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages