summaryrefslogtreecommitdiff
path: root/gitlab/cli.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-03-11 08:36:02 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2018-03-11 08:36:02 +0100
commit7c6be94630d35793e58fafd38625c29779f7a09a (patch)
treed53000c12d51542b9771476bbf775ea1241c5773 /gitlab/cli.py
parentd35a31d1268c6c8edb9f8b8322c5c66cb70ea9ae (diff)
downloadgitlab-7c6be94630d35793e58fafd38625c29779f7a09a.tar.gz
[cli] Restore the --help option behavior
Fixes #381
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r--gitlab/cli.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py
index 36a1bda..91a7dde 100644
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -77,8 +77,8 @@ def cls_to_what(cls):
return camel_re.sub(r'\1-\2', cls.__name__).lower()
-def _get_base_parser():
- parser = argparse.ArgumentParser(
+def _get_base_parser(add_help=True):
+ parser = argparse.ArgumentParser(add_help=add_help,
description="GitLab API Command Line Interface")
parser.add_argument("--version", help="Display the version.",
action="store_true")
@@ -132,14 +132,20 @@ def main():
print(gitlab.__version__)
exit(0)
- parser = _get_base_parser()
+ parser = _get_base_parser(add_help=False)
+ # 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
(options, args) = parser.parse_known_args(sys.argv)
config = gitlab.config.GitlabConfigParser(options.gitlab,
options.config_file)
cli_module = importlib.import_module('gitlab.v%s.cli' % config.api_version)
+
+ # Now we build the entire set of subcommands and do the complete parsing
parser = _get_parser(cli_module)
args = parser.parse_args(sys.argv[1:])
+
config_files = args.config_file
gitlab_id = args.gitlab
verbose = args.verbose