diff options
author | Max Wittig <max.wittig@siemens.com> | 2018-11-04 16:52:32 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvainpocentek@gmail.com> | 2018-11-04 16:52:32 +0100 |
commit | 6ad9da04496f040ae7d95701422434bc935a5a80 (patch) | |
tree | 55020c49fbf3c8519efff6a45b6a4f2cfa93e496 /gitlab/cli.py | |
parent | 742243f4f43042d4b561e3875dc38e560bb71624 (diff) | |
download | gitlab-6ad9da04496f040ae7d95701422434bc935a5a80.tar.gz |
fix(cli): exit on config parse error, instead of crashing
* Exit and hint user about possible errors
* test: adjust test cases to config missing error
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r-- | gitlab/cli.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py index e79ac6d..17917f5 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function + import argparse import functools import importlib @@ -143,9 +144,13 @@ def main(): # 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) + try: + config = gitlab.config.GitlabConfigParser( + options.gitlab, + options.config_file + ) + except gitlab.config.ConfigError as e: + sys.exit(e) 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 |