phrase-cli icon indicating copy to clipboard operation
phrase-cli copied to clipboard

Pagination

Open jimmymcpeter opened this issue 1 year ago • 3 comments

How do you use pagination with the CLI? There's no way to access a response's Link/Pagination HTTP headers.

For example, I need to get a list of 500 keys in my project.

phrase keys list --project_id 123xyz --batch returns the first 25. How do I know there are 475 left?

jimmymcpeter avatar Feb 10 '25 16:02 jimmymcpeter

Yeah, as the pagination data is not exposed in the response body, you won't have the information available.

We could perhaps add an option to output the pagination data as JSON before or after the response body on stdout, however that would pose a problem of parsing, as it's not a single JSON document any more.

jablan avatar Feb 11 '25 09:02 jablan

Thanks jablan. For some inspiration you could take a look at the GitHub CLI's --paginate and --slurp options -- https://cli.github.com/manual/gh_api

jimmymcpeter avatar Feb 11 '25 12:02 jimmymcpeter

I see. As a workaround measure, you can iterate by increasing page parameter until there's no more results left in the response.

jablan avatar Feb 11 '25 12:02 jablan