From a8caddcb1e193c5472f5521dee0e18b1af32c89b Mon Sep 17 00:00:00 2001 From: Hakan Fouren Date: Wed, 6 Mar 2019 01:17:56 +0800 Subject: [PATCH 1/2] Re-enable command specific help mesaages This makes sure that the global help message wont be printed instead of the command spedific one unless we fail to read the configuration file --- gitlab/cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitlab/cli.py b/gitlab/cli.py index 17917f564..5ca456818 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -136,9 +136,6 @@ 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 @@ -150,6 +147,9 @@ def main(): options.config_file ) except gitlab.config.ConfigError as e: + if "--help" in sys.argv or "-h" in sys.argv: + parser.print_help() + exit(0) sys.exit(e) cli_module = importlib.import_module('gitlab.v%s.cli' % config.api_version) From 6fe2988dd050c05b17556cacac4e283fbf5242a8 Mon Sep 17 00:00:00 2001 From: Hakan Fouren Date: Thu, 7 Mar 2019 00:48:51 +0800 Subject: [PATCH 2/2] Use sys.exit as in rest of code --- gitlab/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab/cli.py b/gitlab/cli.py index 5ca456818..b573c7fb2 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -133,7 +133,7 @@ def _parse_value(v): def main(): if "--version" in sys.argv: print(gitlab.__version__) - exit(0) + sys.exit(0) parser = _get_base_parser(add_help=False) @@ -149,7 +149,7 @@ def main(): except gitlab.config.ConfigError as e: if "--help" in sys.argv or "-h" in sys.argv: parser.print_help() - exit(0) + sys.exit(0) sys.exit(e) cli_module = importlib.import_module('gitlab.v%s.cli' % config.api_version)