Expand description
CLI-side pagination walkers.
Mirror of crate::mcp::pagination, but tuned for the CLI’s output model:
these helpers walk pages and return the accumulated raw items as a
Vec<Value> so the existing OutputConfig::print_items machinery can
format them as tables, JSON, or CSV. No compaction, no envelope — just
the loop logic and termination handling shared across every paginated
CLI command.
§Contract
Every walker respects the global pagination flags on crate::Cli:
--all: auto-fetch pages until natural termination or--limithit.--limit N: cap total items returned across pages.--page N(page-style only): manual page selection. With--all, the starting page.--cursor X(cursor-style only): manual cursor. With--all, the starting cursor.--start MS+--start-id ID(start-id-style only): manual boundary pair. With--all, the starting boundary.
--limit is enforced after walking, so --all --limit 500 returns
up to 500 items across N pages rather than truncating the first page to
500. A hard cap of 100 pages prevents runaway loops.
Functions§
- walk_
body - Body-based walker for the v3 audit-log endpoint. POST to
pathwithbase_body() + pagination block; advance vianext_timestamp(last_item).extra_paginationlets the caller pre-populatepageRows/pageDirectionfields the helper doesn’t manage directly. - walk_
cursor - Cursor-based walker for v3 endpoints (
?cursor=X, response carriesnext_cursor: stringor empty).build_path(Option<&str>)returns the URL given an optional cursor.items_keysis the priority list of candidate response keys (e.g.&["data", "channels"]). - walk_
page - Page-based walker for v2 endpoints (
?page=N, response carrieslast_page: bool).build_path(page)returns the URL for a given page.items_keyis the response field holding the array (e.g."tasks"). - walk_
start_ id - Start-id-based walker for v2 comment endpoints
(
?start=<ms>&start_id=<id>paired, response carries{comments: [...]}with termination inferred from short page).build_path(Option<i64>, Option<&str>)returns the URL given an optional boundary pair.items_keyis the response key (typically"comments").