@@ -468,12 +468,30 @@ Value of the output.
468468Void
469469#>
470470function Set-GHActionsOutput {
471- [CmdletBinding ()][OutputType ([void ])]
471+ [CmdletBinding (DefaultParameterSetName = ' 1 ' )][OutputType ([void ])]
472472 param (
473- [Parameter (Mandatory = $true , Position = 0 )][ValidatePattern (' ^.+$' )][Alias (' Key' )][string ]$Name ,
474- [Parameter (Mandatory = $true , Position = 1 )][string ]$Value
473+ [Parameter (Mandatory = $true , ParameterSetName = ' 1' , Position = 0 , ValueFromPipeline = $true )][Alias (' Input' , ' Object' )][hashtable ]$InputObject ,
474+ [Parameter (Mandatory = $true , ParameterSetName = ' 2' , Position = 0 )][ValidatePattern (' ^.+$' )][Alias (' Key' )][string ]$Name ,
475+ [Parameter (Mandatory = $true , ParameterSetName = ' 2' , Position = 1 )][string ]$Value
475476 )
476- Write-GHActionsCommand - Command ' set-output' - Message $Value - Property @ { ' name' = $Name }
477+ begin {}
478+ process {
479+ switch ($PSCmdlet.ParameterSetName ) {
480+ ' 1' { $InputObject.GetEnumerator () | ForEach-Object - Process {
481+ if ($_.Name.GetType ().Name -ne ' string' ) {
482+ Write-Error - Message " Input name `" $ ( $_.Name ) `" must be type of string!" - Category InvalidType
483+ } elseif ($_.Name -notmatch ' ^.+$' ) {
484+ Write-Error - Message " Input name `" $ ( $_.Name ) `" is not match the require pattern!" - Category SyntaxError
485+ } elseif ($_.Value.GetType ().Name -ne ' string' ) {
486+ Write-Error - Message " Input value `" $ ( $_.Value ) `" must be type of string!" - Category InvalidType
487+ } else {
488+ Write-GHActionsCommand - Command ' set-output' - Message $_.Value - Property @ { ' name' = $_.Name }
489+ }
490+ }; break }
491+ ' 2' { Write-GHActionsCommand - Command ' set-output' - Message $Value - Property @ { ' name' = $Name }; break }
492+ }
493+ }
494+ end {}
477495}
478496<#
479497. SYNOPSIS
@@ -488,12 +506,30 @@ Value of the state.
488506Void
489507#>
490508function Set-GHActionsState {
491- [CmdletBinding ()][OutputType ([void ])]
509+ [CmdletBinding (DefaultParameterSetName = ' 1 ' )][OutputType ([void ])]
492510 param (
493- [Parameter (Mandatory = $true , Position = 0 )][ValidatePattern (' ^.+$' )][Alias (' Key' )][string ]$Name ,
494- [Parameter (Mandatory = $true , Position = 1 )][string ]$Value
511+ [Parameter (Mandatory = $true , ParameterSetName = ' 1' , Position = 0 , ValueFromPipeline = $true )][Alias (' Input' , ' Object' )][hashtable ]$InputObject ,
512+ [Parameter (Mandatory = $true , ParameterSetName = ' 2' , Position = 0 )][ValidatePattern (' ^.+$' )][Alias (' Key' )][string ]$Name ,
513+ [Parameter (Mandatory = $true , ParameterSetName = ' 2' , Position = 1 )][string ]$Value
495514 )
496- Write-GHActionsCommand - Command ' save-state' - Message $Value - Property @ { ' name' = $Name }
515+ begin {}
516+ process {
517+ switch ($PSCmdlet.ParameterSetName ) {
518+ ' 1' { $InputObject.GetEnumerator () | ForEach-Object - Process {
519+ if ($_.Name.GetType ().Name -ne ' string' ) {
520+ Write-Error - Message " Input name `" $ ( $_.Name ) `" must be type of string!" - Category InvalidType
521+ } elseif ($_.Name -notmatch ' ^.+$' ) {
522+ Write-Error - Message " Input name `" $ ( $_.Name ) `" is not match the require pattern!" - Category SyntaxError
523+ } elseif ($_.Value.GetType ().Name -ne ' string' ) {
524+ Write-Error - Message " Input value `" $ ( $_.Value ) `" must be type of string!" - Category InvalidType
525+ } else {
526+ Write-GHActionsCommand - Command ' save-state' - Message $_.Value - Property @ { ' name' = $_.Name }
527+ }
528+ }; break }
529+ ' 2' { Write-GHActionsCommand - Command ' save-state' - Message $Value - Property @ { ' name' = $Name }; break }
530+ }
531+ }
532+ end {}
497533}
498534Set-Alias - Name ' Save-GHActionsState' - Value ' Set-GHActionsState' - Option ReadOnly - Scope ' Local'
499535<#
0 commit comments