From 6bb4d17a92832701b9f064a6577488cc42d20645 Mon Sep 17 00:00:00 2001 From: Max Wittig Date: Tue, 2 Oct 2018 19:56:53 +0200 Subject: [PATCH] fix(cli): print help and usage without config file Fixes #560 --- gitlab/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gitlab/cli.py b/gitlab/cli.py index 48701922c..e79ac6d5d 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -98,7 +98,7 @@ def _get_base_parser(add_help=True): "will be used."), required=False) parser.add_argument("-o", "--output", - help=("Output format (v4 only): json|legacy|yaml"), + help="Output format (v4 only): json|legacy|yaml", required=False, choices=['json', 'legacy', 'yaml'], default="legacy") @@ -135,6 +135,10 @@ def main(): exit(0) parser = _get_base_parser(add_help=False) + if "--help" in sys.argv or "-h" in sys.argv: + parser.print_help() + exit(0) + # This first parsing step is used to find the gitlab config to use, and # load the propermodule (v3 or v4) accordingly. At that point we don't have # any subparser setup