13
13
// ----------------------------------------------------------------------------------
14
14
15
15
using System ;
16
+ using System . Collections . Generic ;
16
17
using System . Management . Automation ;
17
18
18
19
namespace Microsoft . Azure . Commands . ResourceManager . Common . ArgumentCompleters
@@ -25,10 +26,22 @@ public PSArgumentCompleterAttribute(params string[] argumentList) : base(CreateS
25
26
26
27
public static ScriptBlock CreateScriptBlock ( string [ ] resourceTypes )
27
28
{
28
- string scriptResourceTypeList = "'" + String . Join ( "' , '" , resourceTypes ) + "'" ;
29
+ List < string > outputResourceTypes = new List < string > ( ) ;
30
+ foreach ( string resourceType in resourceTypes )
31
+ {
32
+ if ( resourceType . Contains ( " " ) )
33
+ {
34
+ outputResourceTypes . Add ( "\' \' " + resourceType + "\' \' " ) ;
35
+ }
36
+ else
37
+ {
38
+ outputResourceTypes . Add ( resourceType ) ;
39
+ }
40
+ }
41
+ string scriptResourceTypeList = "'" + String . Join ( "' , '" , outputResourceTypes ) + "'" ;
29
42
string script = "param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\n " +
30
43
String . Format ( "$values = {0}\n " , scriptResourceTypeList ) +
31
- "$values | Where-Object { $_ -Like \" $wordToComplete*\" } | Sort-Object | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }" ;
44
+ "$values | Where-Object { $_ -Like \" $wordToComplete*\" -or $_ -Like \" '$wordToComplete* \" } | Sort-Object | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }" ;
32
45
ScriptBlock scriptBlock = ScriptBlock . Create ( script ) ;
33
46
return scriptBlock ;
34
47
}
0 commit comments