Skip to content

feat(cli): add dynamic shell completion via clap CompleteEnv - #3916

Merged
afonsojramos merged 8 commits into
spicetify:v3-betafrom
Golevka2001:v3-beta
Sep 4, 2026
Merged

feat(cli): add dynamic shell completion via clap CompleteEnv#3916
afonsojramos merged 8 commits into
spicetify:v3-betafrom
Golevka2001:v3-beta

Conversation

@Golevka2001

@Golevka2001 Golevka2001 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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 ZDOTDIR and XDG_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.

Snipaste_2026-09-03_12-37-40 Snipaste_2026-09-03_12-37-52 Snipaste_2026-09-03_12-39-31 Snipaste_2026-09-03_12-54-19

Copilot AI lite review requested due to automatic review settings September 3, 2026 04:57
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 0a3ca80b-d422-4eb9-965b-7a0ea705822f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 (with unstable-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.

Comment thread rust/crates/cli/src/main.rs Outdated
@Golevka2001

Copy link
Copy Markdown
Contributor Author

Adopted copilot's suggestion~

@Golevka2001

Copy link
Copy Markdown
Contributor Author

@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 --help all the time, haha.

@afonsojramos

Copy link
Copy Markdown
Member

@Golevka2001 yeah, I deleted it because I thought a bit more and I disagreed with what I initially said 😅 Thanks for the PR!

@afonsojramos
afonsojramos merged commit 33a53fe into spicetify:v3-beta Sep 4, 2026
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.

3 participants