Skip to content

feat: add kiqr completion command (bash/zsh/fish)#19

Merged
kjellberg merged 1 commit into
kiqr:mainfrom
kjellbergzoey:feat/shell-completion
Jun 7, 2026
Merged

feat: add kiqr completion command (bash/zsh/fish)#19
kjellberg merged 1 commit into
kiqr:mainfrom
kjellbergzoey:feat/shell-completion

Conversation

@kjellbergzoey

Copy link
Copy Markdown
Contributor

What

Adds a new kiqr completion <bash|zsh|fish> command that prints an idiomatic shell completion script to stdout. Sourcing it gives tab-completion for kiqr's top-level subcommands (up, down, restart, init, info, open, logs, wp, watch, destroy, doctor, db).

Why (the DX win)

Typing kiqr <TAB> and getting the available commands is a meaningful quality-of-life improvement, especially while learning the CLI. The completion script is fully static and deterministic, so the shell can source it on startup without invoking the CLI.

Install

# bash
kiqr completion bash >> ~/.bashrc

# zsh (drop into an fpath dir)
kiqr completion zsh > "${fpath[1]}/_kiqr"

# fish
kiqr completion fish > ~/.config/fish/completions/kiqr.fish

Design

  • src/lib/completion.ts — pure, unit-tested generation. Exports COMPLETION_SHELLS, CompletionShell, KIQR_COMMANDS, isCompletionShell, and generateCompletion(shell, commands). Each shell gets its idiomatic markers (complete -F for bash, #compdef/compdef for zsh, complete -c ... __fish_use_subcommand for fish).
  • src/commands/completion.tsx — thin Pastel command. The shell positional arg is a zod enum over COMPLETION_SHELLS, so unsupported shells produce a clear validation error with the allowed choices.
  • tests/lib/completion.test.ts — asserts each shell returns a non-empty script containing every command name plus the right shell-specific markers, custom command lists are honored, and unknown shells are rejected.

No new files touch shared modules (index.tsx/README.md); Pastel auto-discovers the command.

Verification

  • npm run typecheck, npm test (126 passing), npm run build, npm run lint all green.
  • Smoke-tested the built CLI for all three shells plus an invalid shell (clean error, exit 1).

🤖 Generated with Claude Code

Add a `kiqr completion <bash|zsh|fish>` command that prints an idiomatic
shell completion script to stdout for sourcing into the user's shell.

Generation lives in a pure, unit-tested src/lib/completion.ts; the
src/commands/completion.tsx command is a thin Pastel wrapper that validates
the shell argument against COMPLETION_SHELLS via a zod enum.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kjellberg
kjellberg merged commit fa20f45 into kiqr:main Jun 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants