PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

Add command-completion for PowerShell invocation command line

Open Liturgist opened this issue 4 years ago • 16 comments

Summary of the new feature/enhancement

Command-completion (tab-completion) is a nice capability It would be helpful to have command-completion for parameters when invoking PowerShell from a PowerShell console.

Liturgist avatar Feb 15 '21 16:02 Liturgist

Hi @Liturgist, I want to verify I understand your feature request, from within a PowerShell console or terminal running PowerShell, you want tab-completion to complete the pwsh.exe syntax below? pwsh[.exe] [-Login] [[-File] <filePath> [args]] [-Command { - | [-args ] | [<CommandParameters>] } ] [-ConfigurationName ] [-CustomPipeName ] [-EncodedCommand <Base64EncodedCommand>] [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}] [-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile] [-OutputFormat {Text | XML}] [-SettingsFile <filePath>] [-SSHServerMode] [-STA] [-Version] [-WindowStyle

theJasonHelmick avatar Mar 24 '21 16:03 theJasonHelmick

@theJasonHelmick I'm pretty certain you're right and that's what they're asking for. A build in argument completer for it would be great, I always found it strange that there wasn't one.

SeeminglyScience avatar Mar 26 '21 16:03 SeeminglyScience

This issue has been marked as "Waiting on Author" and has not had any activity for 7 day. It has been closed for housekeeping purposes.

ghost avatar Jan 08 '22 04:01 ghost

@theJasonHelmick, yes, I believe you understand correctly. My apologies for inattention. I still think this would be a helpful addition.

Liturgist avatar Jan 08 '22 16:01 Liturgist

@Liturgist - Thank you for the response and the suggestion -- I think this could be a benefit to customers unfamiliar with pwsh.exe syntax. I'll discuss further with the working group and report back.

theJasonHelmick avatar Jan 17 '22 20:01 theJasonHelmick

We could add completer for pwsh.exe (Register-ArgumentCompleter)

iSazonov avatar Jan 18 '22 04:01 iSazonov

@Liturgist @iSazonov -- After discussing this with the working group, we agree that this would be a beneficial feature for users. I'm marking this up-for-grabs if the community would like to consider building this solution.

theJasonHelmick avatar Jan 20 '22 21:01 theJasonHelmick

Would it be OK to add a reference to System.CommandLine?

powercode avatar May 18 '22 07:05 powercode

Would it be OK to add a reference to System.CommandLine?

Any reference we add essentially version locks that library for anyone else who wants to consume it. There's a pretty high bar for impact that needs to be hit for that to be considered

SeeminglyScience avatar May 18 '22 14:05 SeeminglyScience

On the other hand, others would run into issues using diffferent version of System.CommandLine. It may not be the worst to have it in a dependable way, and it would make writing native completers much easier.

powercode avatar May 18 '22 16:05 powercode

This is still the case. Just waiting for someone to take it on.

PS C:> $psversionTable.psversion.ToString() 7.3.9

Liturgist avatar Nov 16 '23 02:11 Liturgist

This is still the case.

PS C:> $PSVersionTable.PSVersion.ToString() 7.4.2

Liturgist avatar May 16 '24 22:05 Liturgist

@Liturgist I'll take this on. Let me know if someone is already working on it.

jshigetomi avatar Jul 18 '24 16:07 jshigetomi

I made an argument completer for pwsh!

https://gist.github.com/jshigetomi/58cb79de086c804cda3173ef63d7dddf

Please leave some comments and ideas. I hope we can incorporate this completer during runtime once it's approved.

Gist
Tab completion for PowerShell parameters and some parameter arguments - PwshTabCompletion.ps1

jshigetomi avatar Aug 08 '24 04:08 jshigetomi

@jshigetomi, I will look forward to trying it out. Thanks.

Liturgist avatar Aug 08 '24 21:08 Liturgist

This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.

Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.

@jshigetomi, many thanks for your work.

After running PwshTabCompletion.ps1, the completer produces the following parameter names.

-File, -f, -Command, -c, -CommandWithArgs, -cwa, -ConfigurationName, -config, ...

I was expecting...

-File, -Command, -ConfigurationFile, -ConfigurationName, CustomPipeName, ...

Where does CommandWithArgs come from? It does not appear to be in the pwsh help.

    Usage: pwsh[.exe]
        [-Login]
        [[-File] <filePath> [args]]
        [-Command { - | <script-block> [-args <arg-array>]
                      | <string> [<CommandParameters>] } ]
        [-ConfigurationFile <filePath>]
        [-ConfigurationName <string>]
        [-CustomPipeName <string>]
        [-EncodedCommand <Base64EncodedCommand>]
        [-ExecutionPolicy <ExecutionPolicy>]
        [-InputFormat {Text | XML}]
        [-Interactive]
        [-MTA]
        [-NoExit]
        [-NoLogo]
        [-NonInteractive]
        [-NoProfile]
        [-NoProfileLoadTime]
        [-OutputFormat {Text | XML}]
        [-SettingsFile <filePath>]
        [-SSHServerMode]
        [-STA]
        [-Version]
        [-WindowStyle <style>]
        [-WorkingDirectory <directoryPath>]

Liturgist avatar May 06 '25 22:05 Liturgist