Duplicate auto completions; `clap` unaware of the `+toolchain` syntax
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 22h 40m
- Merged PRs (30d)
- 46
Description
Problem
#2031 add a special argument +toolchain, this breaks the zsh completion script generated by clap.
Detail
+toolchain is treated as a positional argument by clap, this brings two problems:
rustup \twill also generate file list because+toolchainis treated as a file.- Maintainer's update: Resolved in #4763.
- the first argument is occupied by
+toolchain, so the completion script thinks the real subcommand starts from the 2nd argument. This means onlyrustup xxx toolchain \twill generate completion fortoolchainsubcommand.
Steps
- generate the completion script:
rustup completions zsh > a_dir_in_fpath/_rustup - type
rustup \t, you will see both rustup commands and local files (they shouldn't exist) in candidates. - type
rustup toolchain \t, you will still see rustup commands, not rustup toolchain commands.
Possible Solution(s)
- Throw this issue to clap
- Use a (semi-)hand-written completion script
- Do a search-and-replace in clap's output
Notes
Output of rustup --version: rustup 1.21.1 (2020-02-23)
Output of rustup show:
Default host: x86_64-unknown-linux-gnu
rustup home: /home/aloxaf/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
nightly-2019-12-20-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-pc-windows-gnu
x86_64-unknown-linux-gnu
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.43.0-nightly (d3c79346a 2020-02-29)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the rustup completions zsh entry point and reproduce completion in the generated _rustup script. Trace how clap represents the +toolchain argument and how that affects the first real subcommand. Done means rustup \t no longer lists local files and rustup toolchain \t offers the toolchain subcommands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, zsh
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100