Use betterhelp's easy mains to get parser off the global.
This commit is contained in:
parent
52963e2fe6
commit
df36ca074d
1 changed files with 20 additions and 17 deletions
11
droidz.py
11
droidz.py
|
@ -388,6 +388,7 @@ def download_argparse(args):
|
|||
for id in args.ids:
|
||||
return download_stick(id, overwrite=args.overwrite, extract=args.extract)
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
subparsers = parser.add_subparsers()
|
||||
|
||||
|
@ -402,10 +403,12 @@ p_download.add_argument('--overwrite', dest='overwrite', action='store_true')
|
|||
p_download.add_argument('--extract', dest='extract', action='store_true')
|
||||
p_download.set_defaults(func=download_argparse)
|
||||
|
||||
@betterhelp.subparser_betterhelp(parser, main_docstring=DOCSTRING, sub_docstrings=SUB_DOCSTRINGS)
|
||||
def main(argv):
|
||||
args = parser.parse_args(argv)
|
||||
return args.func(args)
|
||||
return betterhelp.subparser_main(
|
||||
argv,
|
||||
parser,
|
||||
main_docstring=DOCSTRING,
|
||||
sub_docstrings=SUB_DOCSTRINGS,
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
|
|
Loading…
Reference in a new issue