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:
|
except KeyboardInterrupt:
|
||||||
sql.commit()
|
sql.commit()
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
subparsers = parser.add_subparsers()
|
subparsers = parser.add_subparsers()
|
||||||
|
|
||||||
|
@ -571,10 +572,12 @@ p_render.set_defaults(func=render_argparse)
|
||||||
p_overview = subparsers.add_parser('overview')
|
p_overview = subparsers.add_parser('overview')
|
||||||
p_overview.set_defaults(func=overview_argparse)
|
p_overview.set_defaults(func=overview_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:]))
|
||||||
|
|
Loading…
Reference in a new issue