diff options
author | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2016-01-09 08:47:26 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2016-01-09 08:47:26 +0100 |
commit | 5ea6d0ab7a69000be8ed01eaf2c5a49a79e33215 (patch) | |
tree | 19eb402daa50645c4ccc19448583b3675bca6f8a /gitlab/cli.py | |
parent | 5513d0f52cd488b14c94389a09d01877fa5596e0 (diff) | |
download | gitlab-5ea6d0ab7a69000be8ed01eaf2c5a49a79e33215.tar.gz |
implement group search in CLI
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r-- | gitlab/cli.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py index 53f32af..ab4b17c 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -47,6 +47,7 @@ extra_actions = { gitlab.Project: {SEARCH: {'requiredAttrs': ['query']}, OWNED: {'requiredAttrs': []}, ALL: {'requiredAttrs': []}}, + gitlab.Group: {SEARCH: {'requiredAttrs': ['query']}}, } @@ -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)) @@ -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: |