Skip to content

fix(cli): dynamic shell completion with API-driven resource names#292

Merged
DerDennisOP merged 1 commit into
mainfrom
fix/cli-completion-bin-name
May 29, 2026
Merged

fix(cli): dynamic shell completion with API-driven resource names#292
DerDennisOP merged 1 commit into
mainfrom
fix/cli-completion-bin-name

Conversation

@DerDennisOP
Copy link
Copy Markdown
Member

@DerDennisOP DerDennisOP commented May 29, 2026

Summary

  • Switch the CLI to clap_complete's dynamic completion engine so gradient <TAB> actually works. The old static script registered against the capitalised Gradient app name instead of the gradient binary, which silently disabled completion entirely.
  • Add server-backed completion of existing resource names: organizations, projects, workers, and caches (selectors for select/show/edit/delete/remove, plus organization cache add). Lookups honour the partial prefix and the currently selected organization.
  • Completers run before the tokio runtime starts, each spinning up a short-lived current-thread runtime with a 2s timeout. They fail silently (return no candidates) when offline, logged out, or on any non-2xx/network error, so the shell never errors.
  • gradient completion <shell> re-invokes the binary with COMPLETE=<shell> to emit the dynamic registration stub, keeping the Nix entry point unchanged.

Test plan

  • cli/tests/completion.rsgradient completion {bash,zsh} emits a script registered against the lowercase gradient binary (-F _clap_complete_gradient gradient) and never references Gradient.
  • wiremock-backed unit tests in cli/src/commands/completion.rs — each completer returns resource names, respects the prefix, scopes to the selected org, and yields no candidates on a non-2xx response.
  • cargo clippy --manifest-path cli/Cargo.toml --all-targets passes clean.

@DerDennisOP DerDennisOP merged commit 00fbbf0 into main May 29, 2026
8 checks passed
@DerDennisOP DerDennisOP deleted the fix/cli-completion-bin-name branch May 29, 2026 13:53
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