Skip to content

feat: add shell completion support (bash, zsh, fish)#378

Merged
Wirasm merged 2 commits into
mainfrom
kild/89-shell-completions
Feb 11, 2026
Merged

feat: add shell completion support (bash, zsh, fish)#378
Wirasm merged 2 commits into
mainfrom
kild/89-shell-completions

Conversation

@Wirasm

@Wirasm Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add kild completions <shell> subcommand that generates shell tab-completion scripts using clap_complete
  • Supports bash, zsh, fish, powershell, and elvish
  • Completions are generated dynamically from the clap CLI definition, so they stay in sync as commands change

Usage

# Generate and install completions
kild completions bash > ~/.kild-completions.bash
kild completions zsh > ~/.kild-completions.zsh
kild completions fish > ~/.config/fish/completions/kild.fish

Test plan

  • cargo fmt --check passes
  • cargo clippy --all -- -D warnings passes
  • cargo test --all passes (all 162 tests)
  • cargo build --all succeeds
  • kild completions bash outputs valid bash completion script
  • kild completions zsh outputs valid zsh completion script
  • kild completions fish outputs valid fish completion script
  • kild completions (no arg) errors with usage hint
  • kild completions invalid errors with valid shell options

Closes #89

@Wirasm

Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

PR Review Summary

Critical Issues (1 found)

Agent Issue Location
silent-failure-hunter clap_complete::generate() writes to stdout without error handling. If stdout fails (broken pipe, disk full, redirect to write-protected path), user gets no error and thinks completions were generated. Add std::io::Write + stdout().flush()? after generate call. crates/kild/src/commands/completions.rs:14

Suggestions (2 found)

Agent Suggestion Location
silent-failure-hunter The .ok_or("Shell argument is required")? path is unreachable (clap enforces required args). Consider .expect("shell arg guaranteed by clap") to match intent, though current pattern is consistent with other handlers. crates/kild/src/commands/completions.rs:9
pr-test-analyzer Optional: add integration test verifying kild completions bash produces non-empty output to stdout. Current CLI parsing tests are adequate for the thin handler pattern. crates/kild/tests/cli_output.rs (new)

Strengths

  • Clean, minimal implementation following KISS/YAGNI — thin handler delegates to clap_complete
  • Proper workspace dependency management (clap_complete in root Cargo.toml)
  • Good test coverage: 3 CLI parsing tests covering valid, missing, and invalid shell args
  • Bonus cleanup: moved unused imports in health.rs to test-only scope
  • Follows established command handler patterns consistently

Documentation Updates

  • CLAUDE.md — Added kild completions command examples for all 5 shells (commit 3d1f694)

Verdict

NEEDS FIX — One stdout flush issue to address before merge.

Recommended Actions

  1. Add use std::io::Write; and std::io::stdout().flush()?; after the generate call
  2. Consider the .expect() suggestion (optional — current pattern is consistent)
  3. Integration test for output is nice-to-have, not blocking

Add `kild completions <shell>` that generates shell completion scripts
for bash, zsh, fish, powershell, and elvish using clap_complete.
Completions are generated dynamically from the clap CLI definition so
they stay in sync as commands change.

Closes #89
@Wirasm Wirasm force-pushed the kild/89-shell-completions branch from 3d1f694 to 9c3f787 Compare February 11, 2026 15:36
@Wirasm Wirasm merged commit 5ec3724 into main Feb 11, 2026
4 of 6 checks passed
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.

Add shell completion support (bash, zsh, fish)

1 participant