summaryrefslogtreecommitdiff
path: root/bin/gitlab
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2015-05-12 20:33:26 +0200
committerGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2015-05-12 20:33:30 +0200
commit8b425599bcda4f2c1bf893f78e8773653afacff7 (patch)
tree4d037c7322607cb47b05865837f3f13ed2ff58c0 /bin/gitlab
parentede1224dc3f47faf161111ca1a0911db13462b94 (diff)
downloadgitlab-8b425599bcda4f2c1bf893f78e8773653afacff7.tar.gz
improve handling of id attributes in CLI
closes #31
Diffstat (limited to 'bin/gitlab')
-rwxr-xr-xbin/gitlab12
1 files changed, 7 insertions, 5 deletions
diff --git a/bin/gitlab b/bin/gitlab
index 3967be0..e9b7eb8 100755
--- a/bin/gitlab
+++ b/bin/gitlab
@@ -87,7 +87,9 @@ def populate_sub_parser_by_class(cls, sub_parser):
elif action_name in [GET, DELETE]:
if cls not in [gitlab.CurrentUser]:
- sub_parser_action.add_argument("--id", required=True)
+ id_attr = cls.idAttr.replace('_', '-')
+ sub_parser_action.add_argument("--%s" % id_attr,
+ required=True)
[sub_parser_action.add_argument("--%s" % x.replace('_', '-'),
required=True)
for x in cls.requiredGetAttrs]
@@ -126,11 +128,11 @@ def do_auth():
die("Could not connect to GitLab %s (%s)" % (gitlab_url, str(e)))
-def get_id():
+def get_id(cls):
try:
- id = d.pop('id')
+ id = d.pop(cls.idAttr)
except Exception:
- die("Missing --id argument")
+ die("Missing --%s argument" % cls.idAttr.replace('_', '-'))
return id
@@ -166,7 +168,7 @@ def do_get(cls, d):
id = None
if cls not in [gitlab.CurrentUser]:
- id = get_id()
+ id = get_id(cls)
try:
o = cls(gl, id, **d)