aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
241 stars 79 forks source link

Add ValidateSet to Install-AWSToolsModule -Name property #72

Closed tlindsay42 closed 2 years ago

tlindsay42 commented 4 years ago

Expected Behavior

The Name parameter of the Install-AWSToolsModule cmdlet should use the ValidateSet functionality to provide tab completion of values and more helpful error messages for invalid values.

Current Behavior

The Name parameter of the Install-AWSToolsModule cmdlet does not feature tab completion provided by ValidateSet. Also, the resulting error from invalid values is not very helpful.

PS C:\> Install-AWSToolsModule -Name 'AWS.Tools.*'
ForEach-Object : A positional parameter cannot be found that accepts argument 'System.Collections.Hashtable'.
At ~\Documents\WindowsPowerShell\Modules\AWS.Tools.Installer\1.0.0.0\AWS.Tools.Installer.psm1:250
char:37
+ ... s = $Name | ForEach-Object { Find-Module -Name $_ $findModuleParams @ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [ForEach-Object], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.ForEachObjectCommand

Possible Solution

Add a ValidateSet to the Name parameter of the Install-AWSToolsModule cmdlet.

Context

I had to review the Examples to understand what the valid values were.

PS C:\> man Install-AWSToolsModule -Examples

NAME
    Install-AWSToolsModule

SYNOPSIS
    Install AWS.Tools modules.

    -------------------------- EXAMPLE 1 --------------------------

    PS C:\>Install-AWSToolsModule EC2,S3 -RequiredVersion 4.0.0.0

    This example installs version 4.0.0.0 of AWS.Tools.EC2, AWS.Tools.S3 and their dependencies.

Your Environment

Include as many relevant details about the environment where the bug was discovered.

(Get-Module -Name 'AWS.Tools.Installer').Version

Major  Minor  Build  Revision
-----  -----  -----  --------
1      0      0      0
matteo-prosperi commented 4 years ago

Hi. Thanks for opening this issue. We didn't create a validated set for the Name parameter because it would require updating the AWS.Tools.Installer module every time we add a new AWS.Tools module. Also a user would need to update AWS.Tools.Installer first in order to be able to use it to install other modules. An alternative solution would be to create a completer script like https://github.com/aws/aws-tools-for-powershell/blob/master/modules/ModularAWSPowerShell/AWS.Tools.Common.Completers.psm1.

github-actions[bot] commented 2 years ago

We have noticed this issue has not recieved attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.