Skip to content

Commit

Permalink
Merge pull request #760 from kkoralsky/custom_cli_actions_fix
Browse files Browse the repository at this point in the history
Custom cli actions fix
  • Loading branch information
max-wittig committed May 10, 2019
2 parents 84bcdc0 + 6158fd2 commit e8823e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gitlab/v4/cli.py
Expand Up @@ -80,10 +80,10 @@ def do_custom(self):
if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(self.cls):
data[self.cls._id_attr] = self.args.pop(self.cls._id_attr)
o = self.cls(self.mgr, data)
method_name = self.action.replace('-', '_')
return getattr(o, method_name)(**self.args)
else:
return getattr(self.mgr, self.action)(**self.args)
o = self.mgr
method_name = self.action.replace('-', '_')
return getattr(o, method_name)(**self.args)

def do_project_export_download(self):
try:
Expand Down Expand Up @@ -217,14 +217,14 @@ def _populate_sub_parser_by_class(cls, sub_parser):
for x in mgr_cls._from_parent_attrs]
sub_parser_action.add_argument("--sudo", required=False)

required, optional, needs_id = cli.custom_actions[name][action_name]
# We need to get the object somehow
if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(cls):
if needs_id and gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(cls):
if cls._id_attr is not None:
id_attr = cls._id_attr.replace('_', '-')
sub_parser_action.add_argument("--%s" % id_attr,
required=True)

required, optional, dummy = cli.custom_actions[name][action_name]
[sub_parser_action.add_argument("--%s" % x.replace('_', '-'),
required=True)
for x in required if x != cls._id_attr]
Expand Down

0 comments on commit e8823e9

Please sign in to comment.