Skip to content

fix(cli): don't fail when the short print attr value is None #835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gitlab/cli.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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