You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to pass multiple values to a single parameter in a command, the parameter must be named, otherwise the values get separated/assigned to the next parameter.
Expected Behavior
Passing an array of values to a single positional parameter should assign those values to that parameter.
Current Behavior
Only the first value is associated with the parameter, unless the parameter is named.
Other values are assigned to the next parameter, if there is one. If there is not another, an error occurs.
Possible Solution
Steps to Reproduce (for bugs)
Create a function that has a parameter that can accept an array of values.
Publish that function as a plugin for a PoshBot.
Call the function in Slack using positional parameters.
Attempt to pass an array of values to the positional parameter.
Context
I am using PoshBot to be able to congratulate team members in Slack. I would like to be able to list multiple usernames and have those be passed as an array of values to a parameter that is defined as a string array. For simple use for users, I want the parameter to be positional so that the parameter name isn't needed. However, I cannot pass an array as a positional parameter. Instead, the first value will get passed, and the preceding will be assigned the the next variable. If there is not another variable, an error occurs because PoshBot cannot find a parameter to assign the value to.
Your Environment
Module version used: 0.11.7
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Function FunctionWithArray{
[cmdletbinding()]
[PoshBot.BotCommand(
Aliases = ('test')
)]
param(
[Parameter(Mandatory = $true, Position = 0)][string[]]$param1,
[Parameter(Position = 1)][string]$param2
)
New-PoshBotTextResponse -text "This is param1: $param1"
New-PoshBotTextResponse -text "This is param2: $param2"
}
This should result in the issue. I do not have access to the resources to properly test this, but I'm confident by trying to pass an array of strings to param1 through Slack will cause the issue.
When trying to pass multiple values to a single parameter in a command, the parameter must be named, otherwise the values get separated/assigned to the next parameter.
Expected Behavior
Passing an array of values to a single positional parameter should assign those values to that parameter.
Current Behavior
Only the first value is associated with the parameter, unless the parameter is named.
Other values are assigned to the next parameter, if there is one. If there is not another, an error occurs.
Possible Solution
Steps to Reproduce (for bugs)
Context
I am using PoshBot to be able to congratulate team members in Slack. I would like to be able to list multiple usernames and have those be passed as an array of values to a parameter that is defined as a string array. For simple use for users, I want the parameter to be positional so that the parameter name isn't needed. However, I cannot pass an array as a positional parameter. Instead, the first value will get passed, and the preceding will be assigned the the next variable. If there is not another variable, an error occurs because PoshBot cannot find a parameter to assign the value to.
Your Environment
The text was updated successfully, but these errors were encountered: