Skip to content

Commit

Permalink
Auto merge of #14493 - shannmu:dynamic_switch, r=epage
Browse files Browse the repository at this point in the history
feat: Add native comlpetion with CompleteEnv under the nightly

### What does this PR try to resolve?

Related issue #6645
Tracking issue #14520
This PR is the first step to move cargo shell completions to native completions by using `clap_complete` crate. It makes users could complete cargo subcommand and flags.

By using `clap_complete` crate, we could extend the supported shells to Bash, Zsh, Elvish, Fish, and PowerShell. However, at the current stage, the support for PowerShell in `clap_complete` is not fully developed.
See clap-rs/clap#3166 to get more context about what features `clap_complete` has supported.

### How to test and review this PR?

1. Build a test environment, including the necessary short completion scripts, and the `complete` function to start an interactive shell with the help of a pty device and obtain completion results.
2. Simply test the completion results of subcommands in bash, zsh, fish, elvish.
  • Loading branch information
bors committed Sep 10, 2024
2 parents bd5f32b + 7b0b977 commit e7ca9be
Show file tree
Hide file tree
Showing 7 changed files with 652 additions and 223 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ jobs:
- run: rustup target add ${{ matrix.other }}
- run: rustup component add rustc-dev llvm-tools-preview rust-docs
if: startsWith(matrix.rust, 'nightly')
# Install fish, zsh, and elvish only on Ubuntu systems
- name: Install fish, zsh, and elvish on Ubuntu
run: sudo apt update -y && sudo apt install fish zsh elvish -y
if: matrix.os == 'ubuntu-latest'
- name: Install fish, elvish on macOS
run: brew install fish elvish
if: matrix.os == 'macos-14' || matrix.os == 'macos-13'
- run: sudo apt update -y && sudo apt install lldb gcc-multilib libsecret-1-0 libsecret-1-dev -y
if: matrix.os == 'ubuntu-latest'
- run: rustup component add rustfmt || echo "rustfmt not available"
Expand Down Expand Up @@ -227,6 +234,7 @@ jobs:
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add i686-unknown-linux-gnu
- run: sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y
- run: sudo apt update -y && sudo apt install fish zsh elvish -y
- run: rustup component add rustfmt || echo "rustfmt not available"
- run: cargo test -p cargo
env:
Expand Down
Loading

0 comments on commit e7ca9be

Please sign in to comment.