feat: Add native comlpetion with CompleteEnv under the nightly by shannmu · Pull Request #14493 · rust-lang/cargo (original) (raw)

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.