2
2
# Requires -Version 7.2
3
3
<#
4
4
. SYNOPSIS
5
- GitHub Actions (Internal) - Format Command Parameter
5
+ GitHub Actions (Internal) - Format Command Parameter Value
6
6
. DESCRIPTION
7
- Format command parameter characters that can cause issues.
7
+ Format command parameter value characters that can cause issues.
8
8
. PARAMETER InputObject
9
- String that need to format command parameter characters.
9
+ String that need to format command parameter value characters.
10
10
. OUTPUTS
11
- [String] A string that formatted command parameter characters.
11
+ [String] A string that formatted command parameter value characters.
12
12
#>
13
- Function Format-CommandParameter {
13
+ Function Format-CommandParameterValue {
14
14
[CmdletBinding ()]
15
15
[OutputType ([String ])]
16
16
Param (
17
- [Parameter (Mandatory = $True , Position = 0 )][AllowEmptyString ()][Alias (' Input' , ' Object' )][String ]$InputObject
17
+ [Parameter (Mandatory = $True , Position = 0 , ValueFromPipeline = $True )][AllowEmptyString ()][Alias (' Input' , ' Object' )][String ]$InputObject
18
18
)
19
- Return ((Format-CommandValue - InputObject $InputObject ) -ireplace ' ,' , ' %2C' -ireplace ' :' , ' %3A' )
19
+ Begin {}
20
+ Process {
21
+ Return ((Format-CommandValue - InputObject $InputObject ) -ireplace ' ,' , ' %2C' -ireplace ' :' , ' %3A' )
22
+ }
23
+ End {}
20
24
}
21
- Set-Alias - Name ' Format-CommandProperty ' - Value ' Format-CommandParameter ' - Option ' ReadOnly' - Scope ' Local'
25
+ Set-Alias - Name ' Format-CommandPropertyValue ' - Value ' Format-CommandParameterValue ' - Option ' ReadOnly' - Scope ' Local'
22
26
<#
23
27
. SYNOPSIS
24
28
GitHub Actions (Internal) - Format Command Value
@@ -33,9 +37,13 @@ Function Format-CommandValue {
33
37
[CmdletBinding ()]
34
38
[OutputType ([String ])]
35
39
Param (
36
- [Parameter (Mandatory = $True , Position = 0 )][AllowEmptyString ()][Alias (' Input' , ' Object' )][String ]$InputObject
40
+ [Parameter (Mandatory = $True , Position = 0 , ValueFromPipeline = $True )][AllowEmptyString ()][Alias (' Input' , ' Object' )][String ]$InputObject
37
41
)
38
- Return ($InputObject -ireplace ' %' , ' %25' -ireplace ' \n' , ' %0A' -ireplace ' \r' , ' %0D' )
42
+ Begin {}
43
+ Process {
44
+ Return ($InputObject -ireplace ' %' , ' %25' -ireplace ' \n' , ' %0A' -ireplace ' \r' , ' %0D' )
45
+ }
46
+ End {}
39
47
}
40
48
Set-Alias - Name ' Format-CommandContent' - Value ' Format-CommandValue' - Option ' ReadOnly' - Scope ' Local'
41
49
Set-Alias - Name ' Format-CommandMessage' - Value ' Format-CommandValue' - Option ' ReadOnly' - Scope ' Local'
@@ -46,10 +54,10 @@ GitHub Actions - Write Command
46
54
Write command to communicate with the runner machine.
47
55
. PARAMETER Command
48
56
Command.
49
- . PARAMETER Value
50
- Command value.
51
57
. PARAMETER Parameter
52
58
Command parameter.
59
+ . PARAMETER Value
60
+ Command value.
53
61
. OUTPUTS
54
62
[Void]
55
63
#>
@@ -58,18 +66,16 @@ Function Write-Command {
58
66
[OutputType ([Void ])]
59
67
Param (
60
68
[Parameter (Mandatory = $True , Position = 0 , ValueFromPipelineByPropertyName = $True )][ValidatePattern (' ^(?:[\da-z][\da-z_-]*)?[\da-z]$' , ErrorMessage = ' `{0}` is not a valid GitHub Actions command!' )][String ]$Command ,
61
- [Parameter (Position = 1 , ValueFromPipelineByPropertyName = $True )][Alias (' Content ' , ' Message ' )][String ] $Value = ' ' ,
62
- [Parameter (Position = 2 , ValueFromPipelineByPropertyName = $True )][Alias (' Parameters ' , ' Properties ' , ' Property ' )][Hashtable ] $Parameter = @ {}
69
+ [Parameter (ValueFromPipelineByPropertyName = $True )][Alias (' Parameters ' , ' Properties ' , ' Property ' )][Hashtable ] $Parameter = @ {} ,
70
+ [Parameter (ValueFromPipelineByPropertyName = $True )][Alias (' Content ' , ' Message ' )][String ] $Value = ' '
63
71
)
64
72
Begin {}
65
73
Process {
66
- Write-Host - Object " ::$Command $ ( ($Parameter.Count -igt 0 ) ? " $ ( ($Parameter.GetEnumerator () | Sort-Object - Property ' Name' | ForEach-Object - Process {
67
- Return " $ ( $_.Name ) =$ ( Format-CommandParameter - InputObject $_.Value ) "
68
- }) -join ' ,' ) " : ' ' ) ::$ ( Format-CommandValue - InputObject $Value ) "
69
- }
70
- End {
71
- Return
74
+ Return (Write-Host - Object " ::$Command $ ( ($Parameter.Count -igt 0 ) ? " $ ( ($Parameter.GetEnumerator () | Sort-Object - Property ' Name' | ForEach-Object - Process {
75
+ Return " $ ( $_.Name ) =$ ( Format-CommandParameterValue - InputObject $_.Value ) "
76
+ }) -join ' ,' ) " : ' ' ) ::$ ( Format-CommandValue - InputObject $Value ) " )
72
77
}
78
+ End {}
73
79
}
74
80
Export-ModuleMember - Function @ (
75
81
' Write-Command'
0 commit comments