Add Get-ArgumentCompleter and Unregister-ArgumentCompleter cmdlets#26680
Add Get-ArgumentCompleter and Unregister-ArgumentCompleter cmdlets#26680AndyBodnar wants to merge 1 commit intoPowerShell:masterfrom
Conversation
This change adds two new cmdlets to complement the existing Register-ArgumentCompleter cmdlet: - Get-ArgumentCompleter: Returns registered argument completers with filtering support for command name, parameter name, and native vs PowerShell completers. Supports wildcards. - Unregister-ArgumentCompleter: Removes registered argument completers. Mirrors the parameter sets of Register-ArgumentCompleter for consistency. Also adds ArgumentCompleterInfo class and ArgumentCompleterType enum to expose completer information, and includes tests for the new cmdlets. Fixes PowerShell#25800
|
Some thoughts. |
|
Hey, thanks for the feedback! Yeah I see your point about one completer potentially being registered to multiple commands - that's a fair observation. The reason I went with the command-centric approach is because it kinda mirrors how Register-ArgumentCompleter already works, right? You register a completer for a specific command/parameter combo. So it felt natural for Get-ArgumentCompleter to query along those same lines. Also from a user perspective I figured most people would be thinking "what completers are registered on Get-Process" rather than "show me all commands using this particular scriptblock". At least thats how I tend to think about it when debugging completion issues. That said, I'm totally open to adding something like a -Completer parameter or maybe a grouping option if you think that would be more useful for the scenarios you have in mind. What would you prefer - should I add that as an additional parameter, or were you thinking of a different approach entirely? |
Notice, Register-ArgumentCompleter allows registering one completer for some commands. So Get-ArgumentCompleter should be able to show the information. I don't know that is best solution. We need more discussion in related issue. |
|
anyone available to review this ? |
PR Summary
Hey, this adds the Get-ArgumentCompleter and Unregister-ArgumentCompleter cmdlets that were discussed in #25800. The WG approved adding these back in October 2025 and I noticed the issue was still open, so I figured I'd take a crack at it.
Right now if you register argument completers, there's no way to see what's registered or remove them without restarting your session (or using the null trick with Register-ArgumentCompleter). These two cmdlets fix that.
Get-ArgumentCompleter lets you see all the registered completers. You can filter by command name, parameter name, or use the -Native switch to see native command completers. Wildcards work too, so you can do stuff like
Get-ArgumentCompleter -CommandName "Get-*"to find completers for all Get commands.Unregister-ArgumentCompleter removes completers. I matched the parameter sets to Register-ArgumentCompleter so they feel consistent. You can unregister by command+parameter for PowerShell completers, by command name for native completers, or use -NativeFallback to remove the fallback completer.
I also added an ArgumentCompleterInfo class that Get-ArgumentCompleter returns, and an ArgumentCompleterType enum so you can easily tell if something is a PowerShell completer, native completer, or the native fallback.
PR Context
Fixes #25800
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header