Skip to content

feat: add partial context matching to switch command#194

Open
davidblum wants to merge 1 commit intodanielfoehrKn:masterfrom
davidblum:partial-input-filtering
Open

feat: add partial context matching to switch command#194
davidblum wants to merge 1 commit intodanielfoehrKn:masterfrom
davidblum:partial-input-filtering

Conversation

@davidblum
Copy link

Overview

When running switch <name> with a partial context name, the tool currently requires an exact match or returns an error. This PR adds partial matching support so users can type a substring and select from matching contexts.

Changes

Behavior:

  • Exact match: switches immediately (preserves existing behavior)
  • Partial match: opens fuzzy finder pre-filtered to matching contexts
  • No match: returns error no contexts matching "<name>"

Matching is case-insensitive for partial matches and searches both context names and aliases.

Files changed:

  • pkg/main.go: Added waitForSearchResults() helper and filtering logic in Switcher()
  • cmd/switcher/switcher.go: Unified code path to pass optional desiredContext to Switcher()

Example

# Before: exact match required
switch prod-us-east-1    # works
switch prod              # error: context not found

# After: partial matching
switch prod              # opens picker with contexts containing "prod"
switch prod-us-east-1    # still works (exact match)

When running `switch <name>`, the tool now supports partial matching:
- Exact match: switches immediately (preserves existing behavior)
- Partial match: opens fuzzy finder pre-filtered to matching contexts
- No match: returns helpful error message

Matching is case-insensitive for partial matches and searches both
context names and aliases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant