From 8d1552a0ad137ca5e14fabfc75f7ca034c2a78ca Mon Sep 17 00:00:00 2001 From: xarx00 Date: Mon, 4 Mar 2019 15:15:51 +0100 Subject: [PATCH] fix(cli): don't fail when the short print attr value is None Fixes #717 Fixes #727 --- gitlab/cli.py | 4 ++-- gitlab/tests/test_cli.py | 2 +- gitlab/v4/cli.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gitlab/cli.py b/gitlab/cli.py index 0433a8168..01d885121 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -182,7 +182,7 @@ def main(): if args.fields: fields = [x.strip() for x in args.fields.split(",")] debug = args.debug - action = args.action + action = args.whaction what = args.what args = args.__dict__ @@ -193,7 +193,7 @@ def main(): "verbose", "debug", "what", - "action", + "whaction", "version", "output", ): diff --git a/gitlab/tests/test_cli.py b/gitlab/tests/test_cli.py index bc49d8b45..14854996f 100644 --- a/gitlab/tests/test_cli.py +++ b/gitlab/tests/test_cli.py @@ -116,7 +116,7 @@ def test_parse_args(self): parser = cli._get_parser(gitlab.v4.cli) args = parser.parse_args(["project", "list"]) self.assertEqual(args.what, "project") - self.assertEqual(args.action, "list") + self.assertEqual(args.whaction, "list") def test_parser(self): parser = cli._get_parser(gitlab.v4.cli) diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index f0ed199f1..6fc41aca2 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -312,7 +312,7 @@ def extend_parser(parser): object_group = subparsers.add_parser(arg_name) object_subparsers = object_group.add_subparsers( - title="action", dest="action", help="Action to execute." + title="action", dest="whaction", help="Action to execute." ) _populate_sub_parser_by_class(cls, object_subparsers) object_subparsers.required = True @@ -406,7 +406,7 @@ def display_dict(d, padding): id = getattr(obj, obj._id_attr) print("%s: %s" % (obj._id_attr.replace("_", "-"), id)) if hasattr(obj, "_short_print_attr"): - value = getattr(obj, obj._short_print_attr) + value = getattr(obj, obj._short_print_attr) or "None" value = value.replace("\r", "").replace("\n", " ") # If the attribute is a note (ProjectCommitComment) then we do # some modifications to fit everything on one line