Skip to content

Commit 60599b9

Browse files
committed
Add alias
1 parent e3f5b0a commit 60599b9

File tree

2 files changed

+52
-46
lines changed

2 files changed

+52
-46
lines changed

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psd1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@
105105
'Exit-GHActionsGroup',
106106
'Get-GHActionsEvent',
107107
'Get-GHActionsPayload',
108+
'Restore-GHActionsState',
109+
'Save-GHActionsState',
108110
'Write-GHActionsNote',
109-
'Write-GHActionsWarn'
111+
'Write-GHActionsWarn'
110112
)
111113

112114
# DSC resources to export from this module

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psm1

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ String
2525
function Format-GHActionsCommand {
2626
[CmdletBinding()][OutputType([string])]
2727
param(
28-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][AllowEmptyString()][string]$InputObject,
28+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][AllowEmptyString()][Alias('Input', 'Object')][string]$InputObject,
2929
[switch]$Property
3030
)
3131
begin {}
@@ -51,7 +51,7 @@ Boolean
5151
function Test-GHActionsEnvironmentVariable {
5252
[CmdletBinding()][OutputType([bool])]
5353
param (
54-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][string]$InputObject
54+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][Alias('Input', 'Object')][string]$InputObject
5555
)
5656
begin {}
5757
process {
@@ -72,8 +72,8 @@ An internal function to write workflow command.
7272
Workflow command.
7373
.PARAMETER Message
7474
Message.
75-
.PARAMETER Properties
76-
Workflow command properties.
75+
.PARAMETER Property
76+
Workflow command property.
7777
.OUTPUTS
7878
Void
7979
#>
@@ -82,11 +82,11 @@ function Write-GHActionsCommand {
8282
param (
8383
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][string]$Command,
8484
[Parameter(Mandatory = $true, Position = 1)][AllowEmptyString()][string]$Message,
85-
[Parameter(Position = 2)][hashtable]$Properties = @{}
85+
[Parameter(Position = 2)][Alias('Properties')][hashtable]$Property = @{}
8686
)
8787
[string]$Result = "::$Command"
88-
if ($Properties.Count -gt 0) {
89-
$Result += " $($($Properties.GetEnumerator() | ForEach-Object -Process {
88+
if ($Property.Count -gt 0) {
89+
$Result += " $($($Property.GetEnumerator() | ForEach-Object -Process {
9090
return "$($_.Name)=$(Format-GHActionsCommand -InputObject $_.Value -Property)"
9191
}) -join ',')"
9292
}
@@ -110,8 +110,8 @@ Void
110110
function Add-GHActionsEnvironmentVariable {
111111
[CmdletBinding(DefaultParameterSetName = '1')][OutputType([void])]
112112
param(
113-
[Parameter(Mandatory = $true, ParameterSetName = '1', Position = 0, ValueFromPipeline = $true)]$InputObject,
114-
[Parameter(Mandatory = $true, ParameterSetName = '2', Position = 0)][ValidatePattern('^[\da-z_]+$')][string]$Name,
113+
[Parameter(Mandatory = $true, ParameterSetName = '1', Position = 0, ValueFromPipeline = $true)][Alias('Input', 'Object')]$InputObject,
114+
[Parameter(Mandatory = $true, ParameterSetName = '2', Position = 0)][ValidatePattern('^[\da-z_]+$')][Alias('Key')][string]$Name,
115115
[Parameter(Mandatory = $true, ParameterSetName = '2', Position = 1)][ValidatePattern('^.+$')][string]$Value
116116
)
117117
begin {
@@ -164,7 +164,7 @@ Void
164164
function Add-GHActionsPATH {
165165
[CmdletBinding()][OutputType([void])]
166166
param(
167-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][string[]]$Path
167+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][Alias('Paths')][string[]]$Path
168168
)
169169
begin {
170170
[string[]]$Result = @()
@@ -185,7 +185,7 @@ function Add-GHActionsPATH {
185185
function Add-GHActionsProblemMatcher {
186186
[CmdletBinding()][OutputType([void])]
187187
param (
188-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][SupportsWildcards()][string[]]$Path
188+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][SupportsWildcards()][Alias('File', 'Files', 'Paths', 'PSPath', 'PSPaths')][string[]]$Path
189189
)
190190
begin {}
191191
process {
@@ -212,7 +212,7 @@ Void
212212
function Add-GHActionsSecretMask {
213213
[CmdletBinding()][OutputType([void])]
214214
param(
215-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][string]$Value
215+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][Alias('Key', 'Token')][string]$Value
216216
)
217217
begin {}
218218
process {
@@ -247,7 +247,7 @@ String
247247
function Disable-GHActionsProcessingCommand {
248248
[CmdletBinding()][OutputType([string])]
249249
param(
250-
[Parameter(Position = 0)][ValidatePattern('^.+$')][string]$EndToken = (New-Guid).Guid
250+
[Parameter(Position = 0)][ValidatePattern('^.+$')][Alias('Key', 'Token', 'Value')][string]$EndToken = (New-Guid).Guid
251251
)
252252
Write-GHActionsCommand -Command 'stop-commands' -Message $EndToken
253253
return $EndToken
@@ -280,7 +280,7 @@ Void
280280
function Enable-GHActionsProcessingCommand {
281281
[CmdletBinding()][OutputType([void])]
282282
param(
283-
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][string]$EndToken
283+
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][Alias('Key', 'Token', 'Value')][string]$EndToken
284284
)
285285
Write-GHActionsCommand -Command $EndToken -Message ''
286286
}
@@ -298,7 +298,7 @@ Void
298298
function Enter-GHActionsLogGroup {
299299
[CmdletBinding()][OutputType([void])]
300300
param(
301-
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][string]$Title
301+
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][Alias('Header', 'Message')][string]$Title
302302
)
303303
Write-GHActionsCommand -Command 'group' -Message $Title
304304
}
@@ -334,8 +334,8 @@ Hashtable | String
334334
function Get-GHActionsInput {
335335
[CmdletBinding()][OutputType([hashtable], [string])]
336336
param(
337-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][string[]]$Name,
338-
[switch]$Require,
337+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][Alias('Key', 'Keys', 'Names')][string[]]$Name,
338+
[Alias('Required')][switch]$Require,
339339
[switch]$Trim
340340
)
341341
begin {
@@ -396,7 +396,7 @@ Hashtable | String
396396
function Get-GHActionsState {
397397
[CmdletBinding()][OutputType([hashtable], [string])]
398398
param(
399-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][string[]]$Name,
399+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][Alias('Key', 'Keys', 'Names')][string[]]$Name,
400400
[switch]$Trim
401401
)
402402
begin {
@@ -423,6 +423,7 @@ function Get-GHActionsState {
423423
return $Result
424424
}
425425
}
426+
Set-Alias -Name 'Restore-GHActionsState' -Value 'Get-GHActionsState' -Option ReadOnly -Scope 'Local'
426427
<#
427428
.SYNOPSIS
428429
GitHub Actions - Get Webhook Event Payload
@@ -436,7 +437,7 @@ Hashtable | PSCustomObject
436437
function Get-GHActionsWebhookEventPayload {
437438
[CmdletBinding()][OutputType([hashtable], [pscustomobject])]
438439
param (
439-
[switch]$AsHashTable
440+
[Alias('ToHashTable')][switch]$AsHashTable
440441
)
441442
return (Get-Content -Path $env:GITHUB_EVENT_PATH -Raw -Encoding utf8NoBOM | ConvertFrom-Json -AsHashtable:$AsHashTable)
442443
}
@@ -445,12 +446,12 @@ Set-Alias -Name 'Get-GHActionsPayload' -Value 'Get-GHActionsWebhookEventPayload'
445446
function Remove-GHActionsProblemMatcher {
446447
[CmdletBinding()][OutputType([void])]
447448
param (
448-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][string[]]$Owner
449+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][Alias('Identifies', 'Identify', 'Identifier', 'Identifiers', 'Key', 'Keys', 'Name', 'Names', 'Owners')][string[]]$Owner
449450
)
450451
begin {}
451452
process {
452453
$Owner | ForEach-Object -Process {
453-
Write-GHActionsCommand -Command 'remove-matcher' -Message '' -Properties @{ 'owner' = $_ }
454+
Write-GHActionsCommand -Command 'remove-matcher' -Message '' -Property @{ 'owner' = $_ }
454455
}
455456
}
456457
end {}
@@ -470,10 +471,10 @@ Void
470471
function Set-GHActionsOutput {
471472
[CmdletBinding()][OutputType([void])]
472473
param(
473-
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][string]$Name,
474+
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][Alias('Key')][string]$Name,
474475
[Parameter(Mandatory = $true, Position = 1)][string]$Value
475476
)
476-
Write-GHActionsCommand -Command 'set-output' -Message $Value -Properties @{ 'name' = $Name }
477+
Write-GHActionsCommand -Command 'set-output' -Message $Value -Property @{ 'name' = $Name }
477478
}
478479
<#
479480
.SYNOPSIS
@@ -490,11 +491,12 @@ Void
490491
function Set-GHActionsState {
491492
[CmdletBinding()][OutputType([void])]
492493
param(
493-
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][string]$Name,
494+
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$')][Alias('Key')][string]$Name,
494495
[Parameter(Mandatory = $true, Position = 1)][string]$Value
495496
)
496-
Write-GHActionsCommand -Command 'save-state' -Message $Value -Properties @{ 'name' = $Name }
497+
Write-GHActionsCommand -Command 'save-state' -Message $Value -Property @{ 'name' = $Name }
497498
}
499+
Set-Alias -Name 'Save-GHActionsState' -Value 'Set-GHActionsState' -Option ReadOnly -Scope 'Local'
498500
<#
499501
.SYNOPSIS
500502
GitHub Actions - Write Annotation
@@ -508,7 +510,7 @@ Message that need to log at annotation.
508510
Issue file path.
509511
.PARAMETER Line
510512
Issue file line start.
511-
.PARAMETER Col
513+
.PARAMETER Column
512514
Issue file column start.
513515
.PARAMETER EndLine
514516
Issue file line end.
@@ -524,22 +526,22 @@ function Write-GHActionsAnnotation {
524526
param (
525527
[Parameter(Mandatory = $true, Position = 0)][GHActionsAnnotationType]$Type,
526528
[Parameter(Mandatory = $true, Position = 1)][string]$Message,
527-
[Parameter()][ValidatePattern('^.*$')][string]$File,
529+
[Parameter()][ValidatePattern('^.*$')][Alias('Path')][string]$File,
528530
[Parameter()][uint]$Line,
529-
[Parameter()][uint]$Col,
531+
[Parameter()][Alias('Col')][uint]$Column,
530532
[Parameter()][uint]$EndLine,
531533
[Parameter()][uint]$EndColumn,
532-
[Parameter()][ValidatePattern('^.*$')][string]$Title
534+
[Parameter()][ValidatePattern('^.*$')][Alias('Header')][string]$Title
533535
)
534-
[hashtable]$Properties = @{}
536+
[hashtable]$Property = @{}
535537
if ($File.Length -gt 0) {
536538
$Properties.'file' = $File
537539
}
538540
if ($Line -gt 0) {
539541
$Properties.'line' = $Line
540542
}
541-
if ($Col -gt 0) {
542-
$Properties.'col' = $Col
543+
if ($Column -gt 0) {
544+
$Properties.'col' = $Column
543545
}
544546
if ($EndLine -gt 0) {
545547
$Properties.'endLine' = $EndLine
@@ -550,7 +552,7 @@ function Write-GHActionsAnnotation {
550552
if ($Title.Length -gt 0) {
551553
$Properties.'title' = $Title
552554
}
553-
Write-GHActionsCommand -Command $Type.ToString().ToLower() -Message $Message -Properties $Properties
555+
Write-GHActionsCommand -Command $Type.ToString().ToLower() -Message $Message -Property $Property
554556
}
555557
<#
556558
.SYNOPSIS
@@ -599,14 +601,14 @@ function Write-GHActionsError {
599601
[CmdletBinding()][OutputType([void])]
600602
param (
601603
[Parameter(Mandatory = $true, Position = 0)][string]$Message,
602-
[Parameter()][ValidatePattern('^.*$')][string]$File,
604+
[Parameter()][ValidatePattern('^.*$')][Alias('Path')][string]$File,
603605
[Parameter()][uint]$Line,
604-
[Parameter()][uint]$Col,
606+
[Parameter()][Alias('Col')][uint]$Column,
605607
[Parameter()][uint]$EndLine,
606608
[Parameter()][uint]$EndColumn,
607-
[Parameter()][ValidatePattern('^.*$')][string]$Title
609+
[Parameter()][ValidatePattern('^.*$')][Alias('Header')][string]$Title
608610
)
609-
Write-GHActionsAnnotation -Type 'Error' -Message $Message -File $File -Line $Line -Col $Col -EndLine $EndLine -EndColumn $EndColumn -Title $Title
611+
Write-GHActionsAnnotation -Type 'Error' -Message $Message -File $File -Line $Line -Column $Column -EndLine $EndLine -EndColumn $EndColumn -Title $Title
610612
}
611613
<#
612614
.SYNOPSIS
@@ -652,14 +654,14 @@ function Write-GHActionsNotice {
652654
[CmdletBinding()][OutputType([void])]
653655
param (
654656
[Parameter(Mandatory = $true, Position = 0)][string]$Message,
655-
[Parameter()][ValidatePattern('^.*$')][string]$File,
657+
[Parameter()][ValidatePattern('^.*$')][Alias('Path')][string]$File,
656658
[Parameter()][uint]$Line,
657-
[Parameter()][uint]$Col,
659+
[Parameter()][Alias('Col')][uint]$Column,
658660
[Parameter()][uint]$EndLine,
659661
[Parameter()][uint]$EndColumn,
660-
[Parameter()][ValidatePattern('^.*$')][string]$Title
662+
[Parameter()][ValidatePattern('^.*$')][Alias('Header')][string]$Title
661663
)
662-
Write-GHActionsAnnotation -Type 'Notice' -Message $Message -File $File -Line $Line -Col $Col -EndLine $EndLine -EndColumn $EndColumn -Title $Title
664+
Write-GHActionsAnnotation -Type 'Notice' -Message $Message -File $File -Line $Line -Column $Column -EndLine $EndLine -EndColumn $EndColumn -Title $Title
663665
}
664666
Set-Alias -Name 'Write-GHActionsNote' -Value 'Write-GHActionsNotice' -Option ReadOnly -Scope 'Local'
665667
<#
@@ -688,14 +690,14 @@ function Write-GHActionsWarning {
688690
[CmdletBinding()][OutputType([void])]
689691
param (
690692
[Parameter(Mandatory = $true, Position = 0)][string]$Message,
691-
[Parameter()][ValidatePattern('^.*$')][string]$File,
693+
[Parameter()][ValidatePattern('^.*$')][Alias('Path')][string]$File,
692694
[Parameter()][uint]$Line,
693-
[Parameter()][uint]$Col,
695+
[Parameter()][Alias('Col')][uint]$Column,
694696
[Parameter()][uint]$EndLine,
695697
[Parameter()][uint]$EndColumn,
696-
[Parameter()][ValidatePattern('^.*$')][string]$Title
698+
[Parameter()][ValidatePattern('^.*$')][Alias('Header')][string]$Title
697699
)
698-
Write-GHActionsAnnotation -Type 'Warning' -Message $Message -File $File -Line $Line -Col $Col -EndLine $EndLine -EndColumn $EndColumn -Title $Title
700+
Write-GHActionsAnnotation -Type 'Warning' -Message $Message -File $File -Line $Line -Column $Column -EndLine $EndLine -EndColumn $EndColumn -Title $Title
699701
}
700702
Set-Alias -Name 'Write-GHActionsWarn' -Value 'Write-GHActionsWarning' -Option ReadOnly -Scope 'Local'
701703
Export-ModuleMember -Function @(
@@ -734,6 +736,8 @@ Export-ModuleMember -Function @(
734736
'Exit-GHActionsGroup',
735737
'Get-GHActionsEvent',
736738
'Get-GHActionsPayload',
739+
'Restore-GHActionsState',
740+
'Save-GHActionsState',
737741
'Write-GHActionsNote',
738742
'Write-GHActionsWarn'
739743
)

0 commit comments

Comments
 (0)