Skip to content

Commit

Permalink
Merge pull request #835 from python-gitlab/bugfix-717
Browse files Browse the repository at this point in the history
fix(cli): don't fail when the short print attr value is None
  • Loading branch information
max-wittig committed Jul 21, 2019
2 parents 6c673c6 + 8d1552a commit 0b0a60f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gitlab/cli.py
Expand Up @@ -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__
Expand All @@ -193,7 +193,7 @@ def main():
"verbose",
"debug",
"what",
"action",
"whaction",
"version",
"output",
):
Expand Down
2 changes: 1 addition & 1 deletion gitlab/tests/test_cli.py
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/cli.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0b0a60f

Please sign in to comment.