Add easy mains suitable for most simple use cases.

This commit is contained in:
Ethan Dalool 2020-03-10 22:35:27 -07:00
parent 6eb43fb69d
commit 169c944c38

View file

@ -151,3 +151,17 @@ def subparser_betterhelp(parser, main_docstring, sub_docstrings):
return main(argv)
return wrapped
return wrapper
# EASY MAINS
################################################################################
def single_main(argv, parser, docstring):
def main(argv):
args = parser.parse_args(argv)
return args.func(args)
return single_betterhelp(parser, docstring)(main)(argv)
def subparser_main(argv, parser, main_docstring, sub_docstrings):
def main(argv):
args = parser.parse_args(argv)
return args.func(args)
return subparser_betterhelp(parser, main_docstring, sub_docstrings)(main)(argv)