]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-p4: show detailed help when parsing options fail
authorBen Keene <seraphire@gmail.com>
Mon, 16 Dec 2019 14:02:20 +0000 (14:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Dec 2019 20:32:13 +0000 (12:32 -0800)
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 <seraphire@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py

index 3b3f1469a6eff48d3c3c230367ebb2344cb33c84..9165ada2fd0170430ef7033b4e2617dbb962dd27 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -4145,7 +4145,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: