Use betterhelp's easy main to get parser off the global.
This commit is contained in:
parent
e4b3fa1ca4
commit
8bd48c6607
1 changed files with 27 additions and 24 deletions
|
@ -550,6 +550,7 @@ def update_argparse(args):
|
|||
except KeyboardInterrupt:
|
||||
sql.commit()
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers()
|
||||
|
||||
|
@ -571,10 +572,12 @@ p_render.set_defaults(func=render_argparse)
|
|||
p_overview = subparsers.add_parser('overview')
|
||||
p_overview.set_defaults(func=overview_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