feat(cli): add dynamic shell completion via clap CompleteEnv - #3916
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟡 Changes recommended
The completion interception currently runs after locale initialization, adding avoidable overhead and potential stderr noise to frequent tab-completion invocations.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds dynamic shell completion support to the Rust CLI by integrating clap_complete’s environment-driven completion (CompleteEnv), enabling runtime completion generation across multiple shells.
Changes:
- Add
clap_complete(withunstable-dynamic) as a workspace dependency and wire it into the CLI crate. - Intercept
COMPLETE=<shell>invocations at startup to emit shell completion output and exit.
File summaries
| File | Description |
|---|---|
| rust/crates/cli/src/main.rs | Adds CompleteEnv interception in main() to generate dynamic shell completions. |
| rust/crates/cli/Cargo.toml | Adds clap_complete as a dependency for the CLI crate. |
| rust/Cargo.toml | Adds clap_complete workspace dependency with unstable-dynamic enabled. |
| rust/Cargo.lock | Locks new transitive dependencies introduced by clap_complete. |
Review details
- Files reviewed: 3/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Adopted copilot's suggestion~ |
|
@afonsojramos, sorry-I'm not sure why, but I can't see your reply here, though I did receive your email. I don't really see it as an either/or situation with TUI, to be honest. For me personally, having used this since v2, I actually prefer the plain CLI approach. But sometimes I can't remember the args and end up reaching for |
|
@Golevka2001 yeah, I deleted it because I thought a bit more and I disagreed with what I initially said 😅 Thanks for the PR! |
Adds dynamic shell completion using clap_complete's
CompleteEnv. It covers Bash, Zsh, Fish, PowerShell, and Elvish.The v3 install scripts now register completion automatically in the user's shell configuration. Registration is idempotent, preserves existing content, respects
ZDOTDIRandXDG_CONFIG_HOME, and leaves v2 installs unchanged.Note
The dynamic completion API is still marked unstable. I did try the static route first, but Fish doesn't handle positional arguments correctly (clap-rs/clap#6295).
Worth discussing whether we're comfortable with this.
Validation covers the CLI completion contract and repeat installer runs on macOS, Ubuntu, and Windows.