Skip to content

Commit e45894f

Browse files
committed
Update Scope and ResourceType completers to get contained strings, move logic for Get-AzureRmResource into ProcessRecord
1 parent a8671f0 commit e45894f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/ResourceManager/Common/Commands.ResourceManager.Common/ArgumentCompleters/ResourceTypeCompleter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private static ScriptBlock CreateScriptBlock()
131131
{
132132
string script = "param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\n" +
133133
"$locations = [Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceTypeCompleterAttribute]::GetResourceTypes()\n" +
134-
"$locations | Where-Object { $_ -Like \"$wordToComplete*\" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }";
134+
"$locations | Where-Object { $_ -Like \"*$wordToComplete*\" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }";
135135
ScriptBlock scriptBlock = ScriptBlock.Create(script);
136136
return scriptBlock;
137137
}

src/ResourceManager/Common/Commands.ResourceManager.Common/ArgumentCompleters/ScopeCompleter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private static ScriptBlock CreateScriptBlock()
107107
{
108108
string script = "param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\n" +
109109
"$scopes = [Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ScopeCompleterAttribute]::GetScopes()\n" +
110-
"$scopes | Where-Object { $_ -Like \"$wordToComplete*\" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }";
110+
"$scopes | Where-Object { $_ -Like \"*$wordToComplete*\" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }";
111111
ScriptBlock scriptBlock = ScriptBlock.Create(script);
112112
return scriptBlock;
113113
}

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase
5151
/// Gets or sets the resource name parameter.
5252
/// </summary>
5353
[Alias("Id")]
54-
[Parameter(ParameterSetName = ByResourceIdParameterSet, Mandatory = true)]
54+
[Parameter(ParameterSetName = ByResourceIdParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true)]
5555
[ValidateNotNullOrEmpty]
5656
public string ResourceId { get; set; }
5757

@@ -121,14 +121,6 @@ public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase
121121
protected override void OnProcessRecord()
122122
{
123123
base.OnProcessRecord();
124-
}
125-
126-
/// <summary>
127-
/// Finishes the pipeline execution and runs the cmdlet.
128-
/// </summary>
129-
protected override void OnEndProcessing()
130-
{
131-
base.OnEndProcessing();
132124
this.DefaultApiVersion = string.IsNullOrWhiteSpace(this.ApiVersion) ? Constants.ResourcesApiVersion : this.ApiVersion;
133125
var resourceId = string.Empty;
134126
if (ShouldConstructResourceId(out resourceId))
@@ -151,6 +143,14 @@ protected override void OnEndProcessing()
151143
}
152144
}
153145

146+
/// <summary>
147+
/// Finishes the pipeline execution and runs the cmdlet.
148+
/// </summary>
149+
protected override void OnEndProcessing()
150+
{
151+
base.OnEndProcessing();
152+
}
153+
154154
private void RunSimpleCmdlet()
155155
{
156156
if (this.IsParameterBound(c => c.Tag))

0 commit comments

Comments
 (0)