PSReadLine icon indicating copy to clipboard operation
PSReadLine copied to clipboard

`ShowCommandHelp` and `ShowParameterHelp` should support incomplete parameter names (prefixes)

Open mklement0 opened this issue 2 years ago • 3 comments

Prerequisites

  • [X] Write a descriptive title.

Description of the new feature/enhancement

Currently, for said functions to recognize a parameter and jump to the relevant section in the help file / show the parameter type and description below the command line it must be spelled out in full.

# OK, parameter name spelled out in full
Get-Item -LiteralPath<Alt-h>

# !! NO-OP, because the the parameter name is only identified *by prefix*, not spelled out in full.
Get-Item -Lit<Alt-h>

While tab-completing a parameter-name prefix first bypasses the problem, the need to do so is surprising, given that a unique prefix is sufficient for invocation of a command.

If the prefix isn't unique (e.g. Get-ChildItem -F<Alt-h>), I suggest resolving the problem as follows:

  • ShowCommandHelp: jump to the first parameter with the given prefix.
  • ShowParameterHelp: either do nothing, or display a message indicating the ambiguity.

Proposed technical implementation details (optional)

No response

mklement0 avatar Feb 01 '23 18:02 mklement0

I think the necessary changes would have to be made in Get-Help since all PSReadLine does is make a key handler to call that function.

StevenBucher98 avatar Mar 06 '23 19:03 StevenBucher98

@StevenBucher98:

PSReadLine has control over how how it invokes Get-Help, and the fact that it uses Get-Help at all is an implementation detail.

It should exercise that control in order to translate Get-Item -Lit<Alt-h> to Get-Help Get-Item -Parameter Lit*

Closing this issue as Resolution-External is inappropriate.

mklement0 avatar Mar 07 '23 00:03 mklement0

To hop onto this Issue. Explicit Parameter aliases should be supported too like the ones defined as a [Alias()] attribute.

For instance, the below doesn't work with Alt + h.

icm -HCN

Additionally it would be nice if get-help icm -parameter hcn worked too. Using command aliases works, so I would assume parameter aliases should work at least the explicit ones.

Just linked the Powershell\Powershell repo Issue too.

mattcargile avatar Aug 01 '24 19:08 mattcargile