Skip to content

Add SupportsWildcards attribute to -Repository of Install-PSResource #1808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions src/code/InstallPSResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
/// The Install-PSResource cmdlet installs a resource.
/// It returns nothing.
/// </summary>
[Cmdlet(VerbsLifecycle.Install,
"PSResource",
DefaultParameterSetName = "NameParameterSet",
[Cmdlet(VerbsLifecycle.Install,
"PSResource",
DefaultParameterSetName = "NameParameterSet",
SupportsShouldProcess = true)]
[Alias("isres")]
public sealed
class InstallPSResource : PSCmdlet
{
#region Parameters
#region Parameters

/// <summary>
/// Specifies the exact names of resources to install from a repository.
Expand All @@ -42,7 +42,7 @@ class InstallPSResource : PSCmdlet
[Parameter(ParameterSetName = NameParameterSet, ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string Version { get; set; }

/// <summary>
/// Specifies to allow installation of prerelease versions
/// </summary>
Expand All @@ -53,6 +53,7 @@ class InstallPSResource : PSCmdlet
/// <summary>
/// Specifies the repositories from which to search for the resource to be installed.
/// </summary>
[SupportsWildcards]
[Parameter(ParameterSetName = NameParameterSet, ValueFromPipelineByPropertyName = true)]
[Parameter(ParameterSetName = InputObjectParameterSet, ValueFromPipelineByPropertyName = true)]
[ArgumentCompleter(typeof(RepositoryNameCompleter))]
Expand Down Expand Up @@ -83,9 +84,9 @@ public string TemporaryPath

set
{
if (WildcardPattern.ContainsWildcardCharacters(value))
{
throw new PSArgumentException("Wildcard characters are not allowed in the temporary path.");
if (WildcardPattern.ContainsWildcardCharacters(value))
{
throw new PSArgumentException("Wildcard characters are not allowed in the temporary path.");
}

// This will throw if path cannot be resolved
Expand All @@ -99,7 +100,7 @@ public string TemporaryPath
/// </summary>
[Parameter]
public SwitchParameter TrustRepository { get; set; }

/// <summary>
/// Overwrites a previously installed resource with the same name and version.
/// </summary>
Expand Down Expand Up @@ -130,7 +131,7 @@ public string TemporaryPath
/// </summary>
[Parameter]
public SwitchParameter SkipDependencyCheck { get; set; }

/// <summary>
/// Check validation for signed and catalog files
/// </summary>
Expand Down Expand Up @@ -287,7 +288,7 @@ protected override void ProcessRecord()
pkgCredential: Credential,
reqResourceParams: null);
break;

case InputObjectParameterSet:
foreach (var inputObj in InputObject) {
string normalizedVersionString = Utils.GetNormalizedVersionString(inputObj.Version.ToString(), inputObj.Prerelease);
Expand Down Expand Up @@ -362,7 +363,7 @@ protected override void ProcessRecord()
ErrorCategory.InvalidData,
this));
}

RequiredResourceHelper(pkgsInFile);
break;

Expand All @@ -379,7 +380,7 @@ protected override void ProcessRecord()
}
}
*/

Hashtable pkgsHash = null;
try
{
Expand Down Expand Up @@ -441,7 +442,7 @@ private void RequiredResourceHelper(Hashtable reqResourceHash)
{
var pkgNameEmptyOrWhitespaceError = new ErrorRecord(
new ArgumentException($"The package name '{pkgName}' provided cannot be an empty string or whitespace."),
"pkgNameEmptyOrWhitespaceError",
"pkgNameEmptyOrWhitespaceError",
ErrorCategory.InvalidArgument,
this);

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

Expand Down Expand Up @@ -483,7 +484,7 @@ private void RequiredResourceHelper(Hashtable reqResourceHash)
ThrowTerminatingError(ParameterParsingError);
}
}

if (pkgParams.Scope == ScopeType.AllUsers)
{
_pathsToInstallPkg = Utils.GetAllInstallationPaths(this, pkgParams.Scope);
Expand Down Expand Up @@ -513,10 +514,10 @@ private void ProcessInstallHelper(string[] pkgNames, string pkgVersion, bool pkg
"NameContainsWildcard",
ErrorCategory.InvalidArgument,
this));

return;
}

foreach (string error in errorMsgs)
{
WriteError(new ErrorRecord(
Expand Down