views:

149

answers:

2

Is it possible to implement parameter value tab expansion for enum parameter types?

Creating a binary cmdlet with parameter definition:

[Parameter]
public SomeEnum Type {get;set;} 

Is there some way to type:

Add-MyThing -Type S<tab> 

To get:

Add-MyThing -Type SomeEnumValue

Where:

public enum SomeEnum 
{
   SomeEnumValue,
   SomeEnumValue2
}

I know it may be possible with overriding the TabExpansion function but I was wondering if there was something I could do within my cmdlet to expose this type of functionality.

A: 

After looking into the default TabExpansion function I think it is safe to say, by default, this type of funcitonality does not exist in PowerShell. Getting a hold of a beefed up tab expansion function really is the way to go.

Adam Driscoll
+1  A: 

Parameter parsing and tab-completion are handled by PowerShell. The only extensibility hook for tab-completion is the TabExpansion function you mentioned.

Keith Hill