From 169c944c380928411a18ceaf5e48ad59a7322e05 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 10 Mar 2020 22:35:27 -0700 Subject: [PATCH] Add easy mains suitable for most simple use cases. --- voussoirkit/betterhelp.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/voussoirkit/betterhelp.py b/voussoirkit/betterhelp.py index 6bebdf5..a4a1f23 100644 --- a/voussoirkit/betterhelp.py +++ b/voussoirkit/betterhelp.py @@ -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)