Skip to content

PowerShell completions generate bogus completion flags for all commands #1947

Open
@pingzing

Description

@pingzing

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions