Skip to content

feat: accept a search query as a command-line argument#205

Merged
jongio merged 1 commit into
mainfrom
idea/launch-query
Jul 3, 2026
Merged

feat: accept a search query as a command-line argument#205
jongio merged 1 commit into
mainfrom
idea/launch-query

Conversation

@jongio

@jongio jongio commented Jul 2, 2026

Copy link
Copy Markdown
Owner

What

Lets you pass a search term on the command line so dispatch auth opens the TUI with the search box already filled in and the list filtered to matches.

Today any non-flag token errors out with unknown flag: auth. To search you have to start the TUI, press /, and type. When you already know what you are looking for, passing it on the command line skips those steps and pairs well with shell history and aliases.

How

  • cmd/dispatch/cli.go: handleArgs now collects leading non-flag, non-subcommand tokens and joins them into a query, returned as a new value. Known subcommands (help, version, update, completion, doctor) and unknown flags (leading -) keep their current behavior.
  • cmd/dispatch/main.go: passes the query to the new tui.NewModelWithQuery, and documents dispatch [query] in the usage text.
  • internal/tui/model.go: NewModelWithQuery seeds an initialQuery field; applyInitialQuery puts the model into the same search state as interactive typing (search bar focused and populated, tokens parsed, quick search now, deep search scheduled).
  • internal/tui/handlers.go: handleStoreOpened applies the initial query once, before building the first load command, so the first render is already filtered, then clears it.

Multiple tokens join with spaces, so dispatch fix auth bug searches for fix auth bug. Clearing with esc behaves exactly like an interactively typed query.

Testing

  • go build ./...
  • go vet ./...
  • gofumpt -l . (clean)
  • golangci-lint run --timeout 15m (0 issues)
  • go test ./... -count=1 (all packages pass)

New tests cover argument parsing (single query, multi-word query, subcommands not shadowed, unknown flags still error) in cmd/dispatch/cli_test.go, and that the initial query reaches the model state and is applied on store open in internal/tui/model_search_test.go.

Closes #198

@jongio jongio self-assigned this Jul 2, 2026
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 2, 2026
Treat a leading non-flag, non-subcommand token (or several) as an initial search query so `dispatch auth` or `dispatch fix auth bug` opens the TUI with the search box pre-filled and the list filtered. The query seeds the same search state as typing it interactively: quick search runs immediately with a deep search scheduled to follow.

Closes #198

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jongio jongio force-pushed the idea/launch-query branch from cfa2cff to 1a8c394 Compare July 3, 2026 02:30
@jongio jongio merged commit a7c6601 into main Jul 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start with a search query passed as a command-line argument

1 participant