rust-lang / rust-lang/rustup

Duplicate auto completions; `clap` unaware of the `+toolchain` syntax

Open
#2,268 14 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  1. rustup \t will also generate file list because +toolchain is treated as a file.
    • Maintainer's update: Resolved in #4763.
  2. the first argument is occupied by +toolchain, so the completion script thinks the real subcommand starts from the 2nd argument. This means only rustup xxx toolchain \t will generate completion for toolchain subcommand.

Steps

  1. generate the completion script: rustup completions zsh > a_dir_in_fpath/_rustup
  2. type rustup \t, you will see both rustup commands and local files (they shouldn't exist) in candidates.
  3. type rustup toolchain \t, you will still see rustup commands, not rustup toolchain commands.

Possible Solution(s)

  1. Throw this issue to clap
  2. Use a (semi-)hand-written completion script
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.