git-p4: show detailed help when parsing options fail
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>
Ben Keene committed
Dec 16, 2019 at 14:02 UTC
608e380502f754b50ead6c7e6c3f5ff5ee8eca33
1 file changed
+6
-1
git-p4.py
+6
-1
@@ -4145,7 +4145,12 @@ def main():
4145
description = cmd.description,
4146
formatter = HelpFormatter())
4147
4148
- (cmd, args) = parser.parse_args(sys.argv[2:], cmd);
4148
+ try:
4149
+ (cmd, args) = parser.parse_args(sys.argv[2:], cmd);
4150
+ except:
4151
+ parser.print_help()
4152
+ raise
4153
+
4154
global verbose
4155
verbose = cmd.verbose
4156
if cmd.needsGit: