Skip to content

Commit 9ca47aa

Browse files
author
Gauvain Pocentek
committed
gitlab: update the object syntax
1 parent e7ba350 commit 9ca47aa

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,34 +95,37 @@ The first argument is the object type on which we will act, the second one is
9595
the action:
9696

9797
`````
98-
gitlab Project list
98+
gitlab project list
9999
`````
100100

101101
The usable objects are those which inherits GitlabObject (yes, the source is
102-
the doc ATM), and the actions are list, get, create, update, delete.
102+
the doc ATM), with a bit of string transformation (Project => project,
103+
ProjectIssue => project-issue, ...).
104+
105+
The actions are list, get, create, update, delete.
103106

104107
Some examples:
105108

106109
`````bash
107110
# list all the projects:
108-
gitlab Project list
111+
gitlab project list
109112

110113
# get a specific project (id 2):
111-
gitlab Project get --id=2
114+
gitlab project get --id=2
112115

113116
# get a list of snippets for this project:
114-
gitlab ProjectIssue list --project_id=2
117+
gitlab project-issue list --project_id=2
115118

116119
# delete a Snippet (id 3):
117-
gitlab ProjectSnippet delete --id=3 --project_id=2
120+
gitlab project-snippet delete --id=3 --project_id=2
118121

119122
# update a Snippet:
120-
gitlab ProjectSnippet update --id=4 --project_id=2 --code="My New Code"
123+
gitlab project-snippet update --id=4 --project_id=2 --code="My New Code"
121124

122125
# create a Snippet:
123-
gitlab ProjectSnippet create --project_id=2
126+
gitlab project-snippet create --project_id=2
124127
Impossible to create object (Missing attribute(s): title, file_name, code)
125128

126129
# oops, let's add the attributes:
127-
gitlab ProjectSnippet create --project_id=2 --title="the title" --file_name="the name" --code="the code"
130+
gitlab project-snippet create --project_id=2 --title="the title" --file_name="the name" --code="the code"
128131
`````

gitlab

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ except:
8181
if action not in ['get', 'list', 'update', 'create', 'delete']:
8282
die("Unknown action: %s" % action)
8383

84+
def whatToCls(what):
85+
return "".join([s.capitalize() for s in what.split("-")])
86+
8487
try:
85-
cls = gitlab.__dict__[what]
88+
cls = gitlab.__dict__[whatToCls(what)]
8689
except:
8790
die("Unknown object: %s" % what)
8891

0 commit comments

Comments
 (0)