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>
This commit is contained in:
Ben Keene 2019-12-16 14:02:20 +00:00 коммит произвёл Junio C Hamano
Родитель e2aed5fd5b
Коммит 608e380502
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -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: