Use betterhelp's easy mains to get parser off the global.

This commit is contained in:
Ethan Dalool 2020-03-10 22:39:32 -07:00
parent 52963e2fe6
commit df36ca074d

View file

@ -388,6 +388,7 @@ def download_argparse(args):
for id in args.ids: for id in args.ids:
return download_stick(id, overwrite=args.overwrite, extract=args.extract) return download_stick(id, overwrite=args.overwrite, extract=args.extract)
def main(argv):
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
subparsers = parser.add_subparsers() 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.add_argument('--extract', dest='extract', action='store_true')
p_download.set_defaults(func=download_argparse) p_download.set_defaults(func=download_argparse)
@betterhelp.subparser_betterhelp(parser, main_docstring=DOCSTRING, sub_docstrings=SUB_DOCSTRINGS) return betterhelp.subparser_main(
def main(argv): argv,
args = parser.parse_args(argv) parser,
return args.func(args) main_docstring=DOCSTRING,
sub_docstrings=SUB_DOCSTRINGS,
)
if __name__ == '__main__': if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:])) raise SystemExit(main(sys.argv[1:]))