Skip to content

Commit 8d1552a

Browse files
xarx00max-wittig
authored andcommitted
fix(cli): don't fail when the short print attr value is None
Fixes #717 Fixes #727
1 parent 8306ef2 commit 8d1552a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

gitlab/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def main():
182182
if args.fields:
183183
fields = [x.strip() for x in args.fields.split(",")]
184184
debug = args.debug
185-
action = args.action
185+
action = args.whaction
186186
what = args.what
187187

188188
args = args.__dict__
@@ -193,7 +193,7 @@ def main():
193193
"verbose",
194194
"debug",
195195
"what",
196-
"action",
196+
"whaction",
197197
"version",
198198
"output",
199199
):

gitlab/tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_parse_args(self):
116116
parser = cli._get_parser(gitlab.v4.cli)
117117
args = parser.parse_args(["project", "list"])
118118
self.assertEqual(args.what, "project")
119-
self.assertEqual(args.action, "list")
119+
self.assertEqual(args.whaction, "list")
120120

121121
def test_parser(self):
122122
parser = cli._get_parser(gitlab.v4.cli)

gitlab/v4/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def extend_parser(parser):
312312
object_group = subparsers.add_parser(arg_name)
313313

314314
object_subparsers = object_group.add_subparsers(
315-
title="action", dest="action", help="Action to execute."
315+
title="action", dest="whaction", help="Action to execute."
316316
)
317317
_populate_sub_parser_by_class(cls, object_subparsers)
318318
object_subparsers.required = True
@@ -406,7 +406,7 @@ def display_dict(d, padding):
406406
id = getattr(obj, obj._id_attr)
407407
print("%s: %s" % (obj._id_attr.replace("_", "-"), id))
408408
if hasattr(obj, "_short_print_attr"):
409-
value = getattr(obj, obj._short_print_attr)
409+
value = getattr(obj, obj._short_print_attr) or "None"
410410
value = value.replace("\r", "").replace("\n", " ")
411411
# If the attribute is a note (ProjectCommitComment) then we do
412412
# some modifications to fit everything on one line

0 commit comments

Comments
 (0)