summaryrefslogtreecommitdiff
path: root/gitlab/cli.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2017-09-07 20:56:52 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2017-09-07 20:56:52 +0200
commit0268fc91e9596b8b02c13648ae4ea94ae0540f03 (patch)
treec7c91a1307948103e588ecaddad75485ac1eb146 /gitlab/cli.py
parent947feaf344478fa1b81012124fedaa9de10e224a (diff)
downloadgitlab-0268fc91e9596b8b02c13648ae4ea94ae0540f03.tar.gz
[v4] fix CLI for some mixin methods
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r--gitlab/cli.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py
index f6b357b..be9b112 100644
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -35,7 +35,7 @@ camel_re = re.compile('(.)([A-Z])')
custom_actions = {}
-def register_custom_action(cls_name, mandatory=tuple(), optional=tuple()):
+def register_custom_action(cls_names, mandatory=tuple(), optional=tuple()):
def wrap(f):
@functools.wraps(f)
def wrapped_f(*args, **kwargs):
@@ -43,15 +43,20 @@ def register_custom_action(cls_name, mandatory=tuple(), optional=tuple()):
# in_obj defines whether the method belongs to the obj or the manager
in_obj = True
- final_name = cls_name
- if cls_name.endswith('Manager'):
- final_name = cls_name.replace('Manager', '')
- in_obj = False
- if final_name not in custom_actions:
- custom_actions[final_name] = {}
-
- action = f.__name__
- custom_actions[final_name][action] = (mandatory, optional, in_obj)
+ classes = cls_names
+ if type(cls_names) != tuple:
+ classes = (cls_names, )
+
+ for cls_name in cls_names:
+ final_name = cls_name
+ if cls_name.endswith('Manager'):
+ final_name = cls_name.replace('Manager', '')
+ in_obj = False
+ if final_name not in custom_actions:
+ custom_actions[final_name] = {}
+
+ action = f.__name__.replace('_', '-')
+ custom_actions[final_name][action] = (mandatory, optional, in_obj)
return wrapped_f
return wrap