N
Neal Becker
I want to have subparsers, but I also want to be able to say:
myprogram --version
and get the version #
---------------------------
import argparse
def stop():
pass
parser = argparse.ArgumentParser()
parser.add_argument ('--version', action='store_true')
subparsers = parser.add_subparsers()
parser_stop = subparsers.add_parser ('stop')
parser_stop.add_argument ('stop', action='store_true')
parser_stop.set_defaults (func=stop)
opt = parser.parse_args (['--version'])
myprogram --version
and get the version #
---------------------------
import argparse
def stop():
pass
parser = argparse.ArgumentParser()
parser.add_argument ('--version', action='store_true')
subparsers = parser.add_subparsers()
parser_stop = subparsers.add_parser ('stop')
parser_stop.add_argument ('stop', action='store_true')
parser_stop.set_defaults (func=stop)
opt = parser.parse_args (['--version'])