Use betterhelp easy mains to get parser off the global.

This commit is contained in:
Ethan Dalool 2020-03-10 22:41:09 -07:00
parent 5bc269fd21
commit 4f44cd642f

View file

@ -1654,6 +1654,7 @@ def normalize_argparse(args):
book.move_nav_to_end()
book.save(epub)
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)
subparsers = parser.add_subparsers()
@ -1693,10 +1694,12 @@ p_normalize = subparsers.add_parser('normalize')
p_normalize.add_argument('epubs', nargs='+', default=[])
p_normalize.set_defaults(func=normalize_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:]))