summaryrefslogtreecommitdiff
path: root/gitlab/v4/cli.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-03-17 16:46:18 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2018-03-17 16:46:18 +0100
commit1940feec3dbb099dc3d671cd14ba756e7d34b071 (patch)
tree50c516a33507c9c92ab88c90189445acf5a65cf7 /gitlab/v4/cli.py
parent455a8fc8cab12bbcbf35f04053da84ec0ed1c5c6 (diff)
downloadgitlab-1940feec3dbb099dc3d671cd14ba756e7d34b071.tar.gz
Implement attribute types to handle special cases
Some attributes need to be parsed/modified to work with the API (for instance lists). This patch provides two attribute types that will simplify parts of the code, and fix some CLI bugs. Fixes #443
Diffstat (limited to 'gitlab/v4/cli.py')
-rw-r--r--gitlab/v4/cli.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
index bceba33..0e50de1 100644
--- a/gitlab/v4/cli.py
+++ b/gitlab/v4/cli.py
@@ -45,6 +45,14 @@ class GitlabCLI(object):
self.mgr_cls._path = self.mgr_cls._path % self.args
self.mgr = self.mgr_cls(gl)
+ types = getattr(self.mgr_cls, '_types', {})
+ if types:
+ for attr_name, type_cls in types.items():
+ if attr_name in self.args.keys():
+ obj = type_cls()
+ obj.set_from_cli(self.args[attr_name])
+ self.args[attr_name] = obj.get()
+
def __call__(self):
method = 'do_%s' % self.action
if hasattr(self, method):