Update argparse_multi to also fill in the parser's name.
This commit is contained in:
parent
4e9a3ec0de
commit
4dc033fcf4
1 changed files with 6 additions and 6 deletions
|
@ -10,12 +10,12 @@ def main(argv):
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
subparsers = parser.add_subparsers()
|
subparsers = parser.add_subparsers()
|
||||||
|
|
||||||
p_example = subparsers.add_parser('example1')
|
p_$1 = subparsers.add_parser('$1')
|
||||||
p_example.add_argument('required_positional')
|
p_$1.add_argument('required_positional')
|
||||||
p_example.add_argument('optional_positional', nargs='?', default=None)
|
p_$1.add_argument('optional_positional', nargs='?', default=None)
|
||||||
p_example.add_argument('-k', '--kwarg', dest='kwarg', default=None)
|
p_$1.add_argument('-k', '--kwarg', dest='kwarg', default=None)
|
||||||
p_example.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
|
p_$1.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
|
||||||
p_example.set_defaults(func=$1_argparse)
|
p_$1.set_defaults(func=$1_argparse)
|
||||||
|
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
return args.func(args)
|
return args.func(args)
|
||||||
|
|
Loading…
Reference in a new issue