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