[PATCH 3/3] git-p4: [usability] Show detailed help when parsing options fail
From: Ben Keene via GitGitGadget <hidden>
Date: 2019-12-09 14:16:58
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Ben Keene via GitGitGadget <hidden>
Date: 2019-12-09 14:16:58
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Ben Keene <redacted> When a user provides invalid parameters to git-p4, the program reports the failure but does not provide the correct command syntax. Add an exception handler to the command-line argument parser to display the command's specific command line parameter syntax when an exception is thrown. Rethrow the exception so the current behavior is retained. Signed-off-by: Ben Keene <redacted> --- git-p4.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/git-p4.py b/git-p4.py
index 856fe82079..cb594baeef 100755
--- a/git-p4.py
+++ b/git-p4.py@@ -4166,7 +4166,12 @@ def main(): description = cmd.description, formatter = HelpFormatter()) - (cmd, args) = parser.parse_args(sys.argv[2:], cmd); + try: + (cmd, args) = parser.parse_args(sys.argv[2:], cmd); + except: + parser.print_help() + raise + global verbose verbose = cmd.verbose if cmd.needsGit:
--
gitgitgadget