fix(snippets): implement pagination for snippets list command by angeliski · Pull Request #4879 · supabase/cli

What kind of change does this PR introduce?

Bug fix - Implement pagination support for snippets list command

What is the current behavior?

The supabase snippets list command was not implementing pagination correctly, returning only the first page of results and not fetching subsequent pages via cursor-based pagination.

Related to #4858

I

What is the new behavior?

✅ Implemented cursor-based pagination that:

  • Fetches all snippets across multiple pages sequentially
  • Tracks cursor between API calls to fetch next pages
  • Properly terminates when no more pages are available
  • Supports JSON, TOML, and table output formats

Example usage:

# Fetches all snippets (pagination handled automatically)
supabase snippets list --project-ref <ref>

# With JSON output
supabase snippets list --project-ref <ref> -o json

Additional context

Design Decision - Pagination-Only Approach:

This PR intentionally focuses on implementing pagination without introducing additional filtering or sorting parameters (e.g., --limit, --sort-by, --sort-order). The rationale behind this approach:

Consistency: Follows the existing CLI pattern where pagination is handled transparently without user-exposed parameters
Simplicity: Reduces cognitive load - users simply run the command and get all results, without needing to understand pagination mechanics
API Alignment: Mirrors the behavior of similar Supabase CLI commands (databases list, functions list, etc.)
Scope: Keeps the fix focused on resolving the reported issue without scope creep
Future Improvements:

Sorting and limiting capabilities could be valuable additions in a subsequent PR if deemed necessary:

--limit could cap the number of results retrieved
--sort-by and --sort-order could organize results (though the API's cursor-based model makes client-side sorting more practical)
However, pagination (fetching all available results) was the primary blocker and is now fully functional.