summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2013-05-19 06:31:36 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2013-05-19 06:31:36 +0200
commit34e4304812c29f9ac3eec8bef69d6cf359fff6ae (patch)
tree0c71969d0de48e8b5962ba5873894ecbc5c49479 /gitlab
parent49eab9194dfa1bd264cfb3e19c762c57b2094a01 (diff)
downloadgitlab-34e4304812c29f9ac3eec8bef69d6cf359fff6ae.tar.gz
gitlab: warn the user if an action cannot be performed
Diffstat (limited to 'gitlab')
-rwxr-xr-xgitlab15
1 files changed, 15 insertions, 0 deletions
diff --git a/gitlab b/gitlab
index d662538..0a7e69f 100755
--- a/gitlab
+++ b/gitlab
@@ -87,6 +87,9 @@ if gitlab.GitlabObject not in getmro(cls):
die("Unknown object: %s" % what)
if action == "create":
+ if not cls.canCreate:
+ die("%s objects can't be created" % what)
+
try:
o = cls(gl, d)
o.save()
@@ -96,6 +99,9 @@ if action == "create":
sys.exit(0)
elif action == "list":
+ if not cls.canList:
+ die("%s objects can't be listed" % what)
+
try:
l = cls.list(gl, **d)
except Exception as e:
@@ -108,6 +114,9 @@ elif action == "list":
sys.exit(0)
elif action == "get":
+ if not cls.canGet:
+ die("%s objects can't be retrieved" % what)
+
try:
id = d.pop('id')
except:
@@ -123,6 +132,9 @@ elif action == "get":
sys.exit(0)
elif action == "delete":
+ if not cls.canDelete:
+ die("%s objects can't be deleted" % what)
+
try:
id = d.pop('id')
except:
@@ -141,6 +153,9 @@ elif action == "delete":
sys.exit(0)
elif action == "update":
+ if not cls.canDelete:
+ die("%s objects can't be updated" % what)
+
try:
id = d.pop('id')
except: