Skip to content

Commit

Permalink
implement group search in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed Jan 9, 2016
1 parent 5513d0f commit 5ea6d0a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions gitlab/cli.py
Expand Up @@ -47,6 +47,7 @@
gitlab.Project: {SEARCH: {'requiredAttrs': ['query']},
OWNED: {'requiredAttrs': []},
ALL: {'requiredAttrs': []}},
gitlab.Group: {SEARCH: {'requiredAttrs': ['query']}},
}


Expand Down Expand Up @@ -209,23 +210,30 @@ def do_update(cls, gl, what, args):
return o


def do_group_search(gl, what, args):
try:
return gl.groups.search(args['query'])
except Exception as e:
die("Impossible to search projects (%s)" % str(e))


def do_project_search(gl, what, args):
try:
return gl.search_projects(args['query'])
return gl.projects.search(args['query'])
except Exception as e:
die("Impossible to search projects (%s)" % str(e))


def do_project_all(gl, what, args):
try:
return gl.all_projects()
return gl.projects.all()
except Exception as e:
die("Impossible to list all projects (%s)" % str(e))


def do_project_owned(gl, what, args):
try:
return gl.owned_projects()
return gl.projects.owned()
except Exception as e:
die("Impossible to list owned projects (%s)" % str(e))

Expand Down Expand Up @@ -312,10 +320,15 @@ def main():
getattr(o, action)()

elif action == SEARCH:
if cls != gitlab.Project:

if cls == gitlab.Project:
l = do_project_search(gl, what, args)
elif cls == gitlab.Group:
l = do_group_search(gl, what, args)
else:
die("%s objects don't support this request" % what)

for o in do_project_search(gl, what, args):
for o in l:
o.display(verbose)

elif action == OWNED:
Expand Down

0 comments on commit 5ea6d0a

Please sign in to comment.