gitlab icon indicating copy to clipboard operation
gitlab copied to clipboard

It's not possible to use pages from the CLI

Open nickbroon opened this issue 12 years ago • 5 comments

It would be nice to be able to get more than the default 20 results from a query when using the CLI commands.

nickbroon avatar Aug 21 '14 20:08 nickbroon

More than nice, I think that this functionnality is a requirement and should be flagged as a bug rather than an enhancement. At our site, we're dealing with 200+ projects and we're unable to use the CLI because of this behavior.

riton avatar Nov 26 '14 12:11 riton

Maybe that a new method fetch_all_pages() should be implemented and could be used in the CLI and in other objects. A syntax like

gitlab_client.fetch_all_projects_pages(options) do |results|
  # deal with the results
end

could be nice and avoid a full results buffering.

riton avatar Nov 26 '14 12:11 riton

You can use pagination in the CLI by passing the options as a quoted hash:

$ gitlab users "{ per_page: 100, page: 2 }"

chrisdambrosio avatar Dec 07 '14 20:12 chrisdambrosio

Ok, nice to know. Even with that, IMHO, this is not really a wanted behavior in a CLI. For instance, in Openstack clients, when you list all the VMs that are available with nova show, you do not expect to see only the N first VMs, then have to increment a page and query again.

I think that a CLI should return all the results (even if behind the scene multiple requests have to be made). I just can't imagine something like for page in {1..100}; do gitlab users "{per_page: 42, page: ${page}}". Every CLI users would have to develop their own alias or function wrapper on top of that CLI to only fetch all the results.

This is not really that hard to modify the CLI behavior, (especially if a mechanism such as a gitlab_client.fetch_all_OBJECTS_pages() exists) and I think it's worth the effort.

riton avatar Dec 08 '14 06:12 riton

@riton you can't fetch all records with GitLab API (max is 100 per page). Anyway loading all records to terminal doesn't make a sense. Better implementation is to allow pagination via keys N (next), P (prev) or space. Feel free to open a new issue if you'd like to discuss further.

NARKOZ avatar Dec 09 '14 14:12 NARKOZ