X Tutup
Skip to content

Commit 5ea6d0a

Browse files
author
Gauvain Pocentek
committed
implement group search in CLI
1 parent 5513d0f commit 5ea6d0a

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

gitlab/cli.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
gitlab.Project: {SEARCH: {'requiredAttrs': ['query']},
4848
OWNED: {'requiredAttrs': []},
4949
ALL: {'requiredAttrs': []}},
50+
gitlab.Group: {SEARCH: {'requiredAttrs': ['query']}},
5051
}
5152

5253

@@ -209,23 +210,30 @@ def do_update(cls, gl, what, args):
209210
return o
210211

211212

213+
def do_group_search(gl, what, args):
214+
try:
215+
return gl.groups.search(args['query'])
216+
except Exception as e:
217+
die("Impossible to search projects (%s)" % str(e))
218+
219+
212220
def do_project_search(gl, what, args):
213221
try:
214-
return gl.search_projects(args['query'])
222+
return gl.projects.search(args['query'])
215223
except Exception as e:
216224
die("Impossible to search projects (%s)" % str(e))
217225

218226

219227
def do_project_all(gl, what, args):
220228
try:
221-
return gl.all_projects()
229+
return gl.projects.all()
222230
except Exception as e:
223231
die("Impossible to list all projects (%s)" % str(e))
224232

225233

226234
def do_project_owned(gl, what, args):
227235
try:
228-
return gl.owned_projects()
236+
return gl.projects.owned()
229237
except Exception as e:
230238
die("Impossible to list owned projects (%s)" % str(e))
231239

@@ -312,10 +320,15 @@ def main():
312320
getattr(o, action)()
313321

314322
elif action == SEARCH:
315-
if cls != gitlab.Project:
323+
324+
if cls == gitlab.Project:
325+
l = do_project_search(gl, what, args)
326+
elif cls == gitlab.Group:
327+
l = do_group_search(gl, what, args)
328+
else:
316329
die("%s objects don't support this request" % what)
317330

318-
for o in do_project_search(gl, what, args):
331+
for o in l:
319332
o.display(verbose)
320333

321334
elif action == OWNED:

0 commit comments

Comments
 (0)
X Tutup