Skip to content

feat(cli): add shell completion support#974

Open
nekomoyi wants to merge 5 commits intovoidzero-dev:mainfrom
nekomoyi:feat/cli-completion
Open

feat(cli): add shell completion support#974
nekomoyi wants to merge 5 commits intovoidzero-dev:mainfrom
nekomoyi:feat/cli-completion

Conversation

@nekomoyi
Copy link
Contributor

@nekomoyi nekomoyi commented Mar 16, 2026

Summary

Implements shell completion for the vp CLI.

Changes

Completion scripts for bash, zsh, fish, and PowerShell are generated in ~/.vite-plus/completion/ when running vp env setup, and automatically sourced in the respective env files.

Fixes

Fixed mixed path separators in env files on Windows to use forward slashes consistently for $HOME-relative paths

# Before
__vp_bin="$HOME/.vite-plus\bin"
# After
__vp_bin="$HOME/.vite-plus/bin"

Increased stack size to 8MB to handle deep recursion in clap_complete::generate() which exceeds Windows' default stack size.

Closes #950

@netlify
Copy link

netlify bot commented Mar 16, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 84ad6ae
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69bb8da8ae49b40008fa26b5

@fengmk2 fengmk2 self-requested a review March 17, 2026 03:39
@nekomoyi
Copy link
Contributor Author

Looking into the CI failure.

@nekomoyi nekomoyi marked this pull request as draft March 17, 2026 07:22
@nekomoyi nekomoyi marked this pull request as ready for review March 17, 2026 08:32
Copy link
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

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

@nekomoyi Thanks! I will merge after successful local verification.

[target.'cfg(target_os = "linux")']
rustflags = ["--cfg", "tokio_unstable", "-C", "link-args=-Wl,--warn-unresolved-symbols"]

# Increase stack size on Windows to avoid stack overflow
Copy link
Member

Choose a reason for hiding this comment

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

@nekomoyi Is it caused by the newly introduced clap_complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is the root cause.However, I believe this is an underlying issue of clap on Windows, and the recursive generate process of clap_complete exposed it.
clap-rs/clap#5134

@wtto00
Copy link

wtto00 commented Mar 19, 2026

There is a bug in the __vp_bin path configuration. Please see #1039.

@fengmk2
Copy link
Member

fengmk2 commented Mar 19, 2026

@nekomoyi can you rebase and fix conflicts?

…ive paths

Fix mixed path separators in env files on Windows
- Before: $HOME/.vite-plus\bin (mixed)
- After: $HOME/.vite-plus/bin (consistent)
Simplify completion generation with loop-based approach
…dows

- Increase stack size to 8MB on Windows
- Set RUST_MIN_STACK to 8MB in CI test jobs

Cargo test default (2MB) are insufficient for deep recursion in clap_complete::generate(). This causes stack overflow when generating shell completion scripts during tests.
@nekomoyi nekomoyi force-pushed the feat/cli-completion branch from 0d02ce0 to 9fb37ec Compare March 19, 2026 05:21
@fengmk2 fengmk2 self-assigned this Mar 19, 2026
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.

Shell completion support

3 participants