rust-lang / rust-lang/rustup

PowerShell completions generate bogus completion flags for all commands

Open
#1,947 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug O-windows
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
22h 40m
Merged PRs (30d)
46

Description

Problem
The generated completions for PowerShell incorrectly contain the following completions for the following flags for every option:

  • -h
  • h
  • --help
  • help
  • -V
  • V
  • version
  • --version

...even for commands that do not accept those flags. The result is that if I type

> rustup help

...and then press Tab, I get -h as a suggested autocompletion, which is invalid.

Steps

  1. rustup completions powershell
  2. See output. I'll attach the full contents of the generated completions in a follow-up comment.

Possible Solution(s)
At a guess (I couldn't find where in the repo the completions are actually created), it seems like these four completions get added to every possible command, instead of only those that actually accept it:

[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')

Notes

Output of rustup --version: rustup 1.18.3 (435397f48 2019-05-22)
Output of rustup show:

Default host: x86_64-pc-windows-msvc

installed toolchains
--------------------

stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc

active toolchain
----------------

stable-x86_64-pc-windows-msvc (default)
rustc 1.31.0 (abe02cefd 2018-12-04)

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 at the rustup completions powershell entry point and reproduce the generated PowerShell output described in the issue. Trace how command options become CompletionResult entries, then verify that help and version flags appear only for commands that accept them; no specific test or source file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.