Skip to content

Commit e2a238b

Browse files
authored
Add SupportsWildcards attribute to Repository parameter of Install-PSResource (#1808)
1 parent 3c437c4 commit e2a238b

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/code/InstallPSResource.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
1717
/// The Install-PSResource cmdlet installs a resource.
1818
/// It returns nothing.
1919
/// </summary>
20-
[Cmdlet(VerbsLifecycle.Install,
21-
"PSResource",
22-
DefaultParameterSetName = "NameParameterSet",
20+
[Cmdlet(VerbsLifecycle.Install,
21+
"PSResource",
22+
DefaultParameterSetName = "NameParameterSet",
2323
SupportsShouldProcess = true)]
2424
[Alias("isres")]
2525
public sealed
2626
class InstallPSResource : PSCmdlet
2727
{
28-
#region Parameters
28+
#region Parameters
2929

3030
/// <summary>
3131
/// Specifies the exact names of resources to install from a repository.
@@ -42,7 +42,7 @@ class InstallPSResource : PSCmdlet
4242
[Parameter(ParameterSetName = NameParameterSet, ValueFromPipelineByPropertyName = true)]
4343
[ValidateNotNullOrEmpty]
4444
public string Version { get; set; }
45-
45+
4646
/// <summary>
4747
/// Specifies to allow installation of prerelease versions
4848
/// </summary>
@@ -53,6 +53,7 @@ class InstallPSResource : PSCmdlet
5353
/// <summary>
5454
/// Specifies the repositories from which to search for the resource to be installed.
5555
/// </summary>
56+
[SupportsWildcards]
5657
[Parameter(ParameterSetName = NameParameterSet, ValueFromPipelineByPropertyName = true)]
5758
[Parameter(ParameterSetName = InputObjectParameterSet, ValueFromPipelineByPropertyName = true)]
5859
[ArgumentCompleter(typeof(RepositoryNameCompleter))]
@@ -83,9 +84,9 @@ public string TemporaryPath
8384

8485
set
8586
{
86-
if (WildcardPattern.ContainsWildcardCharacters(value))
87-
{
88-
throw new PSArgumentException("Wildcard characters are not allowed in the temporary path.");
87+
if (WildcardPattern.ContainsWildcardCharacters(value))
88+
{
89+
throw new PSArgumentException("Wildcard characters are not allowed in the temporary path.");
8990
}
9091

9192
// This will throw if path cannot be resolved
@@ -99,7 +100,7 @@ public string TemporaryPath
99100
/// </summary>
100101
[Parameter]
101102
public SwitchParameter TrustRepository { get; set; }
102-
103+
103104
/// <summary>
104105
/// Overwrites a previously installed resource with the same name and version.
105106
/// </summary>
@@ -130,7 +131,7 @@ public string TemporaryPath
130131
/// </summary>
131132
[Parameter]
132133
public SwitchParameter SkipDependencyCheck { get; set; }
133-
134+
134135
/// <summary>
135136
/// Check validation for signed and catalog files
136137
/// </summary>
@@ -287,7 +288,7 @@ protected override void ProcessRecord()
287288
pkgCredential: Credential,
288289
reqResourceParams: null);
289290
break;
290-
291+
291292
case InputObjectParameterSet:
292293
foreach (var inputObj in InputObject) {
293294
string normalizedVersionString = Utils.GetNormalizedVersionString(inputObj.Version.ToString(), inputObj.Prerelease);
@@ -362,7 +363,7 @@ protected override void ProcessRecord()
362363
ErrorCategory.InvalidData,
363364
this));
364365
}
365-
366+
366367
RequiredResourceHelper(pkgsInFile);
367368
break;
368369

@@ -379,7 +380,7 @@ protected override void ProcessRecord()
379380
}
380381
}
381382
*/
382-
383+
383384
Hashtable pkgsHash = null;
384385
try
385386
{
@@ -441,7 +442,7 @@ private void RequiredResourceHelper(Hashtable reqResourceHash)
441442
{
442443
var pkgNameEmptyOrWhitespaceError = new ErrorRecord(
443444
new ArgumentException($"The package name '{pkgName}' provided cannot be an empty string or whitespace."),
444-
"pkgNameEmptyOrWhitespaceError",
445+
"pkgNameEmptyOrWhitespaceError",
445446
ErrorCategory.InvalidArgument,
446447
this);
447448

@@ -454,7 +455,7 @@ private void RequiredResourceHelper(Hashtable reqResourceHash)
454455
{
455456
var requiredResourceHashtableInputFormatError = new ErrorRecord(
456457
new ArgumentException($"The RequiredResource input with name '{pkgName}' does not have a valid value, the value must be a hashtable."),
457-
"RequiredResourceHashtableInputFormatError",
458+
"RequiredResourceHashtableInputFormatError",
458459
ErrorCategory.InvalidArgument,
459460
this);
460461

@@ -483,7 +484,7 @@ private void RequiredResourceHelper(Hashtable reqResourceHash)
483484
ThrowTerminatingError(ParameterParsingError);
484485
}
485486
}
486-
487+
487488
if (pkgParams.Scope == ScopeType.AllUsers)
488489
{
489490
_pathsToInstallPkg = Utils.GetAllInstallationPaths(this, pkgParams.Scope);
@@ -513,10 +514,10 @@ private void ProcessInstallHelper(string[] pkgNames, string pkgVersion, bool pkg
513514
"NameContainsWildcard",
514515
ErrorCategory.InvalidArgument,
515516
this));
516-
517+
517518
return;
518519
}
519-
520+
520521
foreach (string error in errorMsgs)
521522
{
522523
WriteError(new ErrorRecord(

0 commit comments

Comments
 (0)