lzybkr / TabExpansionPlusPlus

A V3 PowerShell module to improve tab expansion and Intellisense
BSD 2-Clause "Simplified" License
196 stars 33 forks source link

Adding ParameterType support to Get-CommandWithParameter #18

Open ShayLevy opened 11 years ago

ShayLevy commented 11 years ago

Is there a reason why Get-CommandWithParameter doesn't support the ParameterType parameter?

With regard to command parameters, currently, Get-CommandWithParameter allows filtering ParameterName only. Having ParameterType will enable another layer of filtering to the current filtering capabilities of the Get-CommandWithParameter function.

lzybkr commented 11 years ago

No reason other than not having run across a need for it.

Note that unlike Get-Command, the parameter name is required because completers don't currently work purely by the parameter type.


From: Shay Levymailto:notifications@github.com Sent: ý7/ý14/ý2013 6:20 AM To: lzybkr/TabExpansionPlusPlusmailto:TabExpansionPlusPlus@noreply.github.com Subject: [TabExpansionPlusPlus] Adding ParameterType support to Get-CommandWithParameter (#18)

Is there a reason why Get-CommandWithParameter doesn't support the ParameterType parameter?

With regard to command parameters, currently, Get-CommandWithParameter allows filtering ParameterName only. Having ParameterType will enable another layer of filtering to the current filtering capabilities of the Get-CommandWithParameter function.

— Reply to this email directly or view it on GitHubhttps://github.com/lzybkr/TabExpansionPlusPlus/issues/18.

ShayLevy commented 11 years ago

So, no plans to add it?

lzybkr commented 11 years ago

Only if there is a definite need.


From: Shay Levymailto:notifications@github.com Sent: ý7/ý14/ý2013 7:47 AM To: lzybkr/TabExpansionPlusPlusmailto:TabExpansionPlusPlus@noreply.github.com Cc: Jasonmailto:jason@truewheels.net Subject: Re: [TabExpansionPlusPlus] Adding ParameterType support to Get-CommandWithParameter (#18)

So, no plans to add it?

— Reply to this email directly or view it on GitHubhttps://github.com/lzybkr/TabExpansionPlusPlus/issues/18#issuecomment-20937389.

ShayLevy commented 11 years ago

Fair enough.

ShayLevy commented 11 years ago

Here's a good example why ParameterType should be added.

Many modules (e.g such as AD,Exchange,SharePoint, etc) makes extensive use of the Identity parameter, to specify the object to operate on.

When writing custom completers for a bunch of commands and for a specific parameter (e.g Identity) we use the Get-CommandWithParameter function along with the parameter name in question.

That covers most cases and allows us to group those commands with a specific parameter name/verb/noun to narrow down the result. But it lacks flexibility/efficiency, especially when the Identity parameter is outside the group of commands grouped by the above.

Let's take the AD commands as an example, there are 9 commands that supports the Identity parameter by the
Microsoft.ActiveDirectory.Management.ADAccount type, but not all commands share the same verb or noun so you can't group all those commands with a single Get-CommandWithParameter command.

Having ParameterType solves it all and can help reduce the amount of completers needed for the job, and imo much safer to use. With a single query we can create completers for a specific type of parameter without having to worry, or rely, on the name of the command.

favorini commented 10 years ago

+1 for adding -ParameterType for exactly the reason stated above