@@ -133,15 +133,19 @@ Print a debug message to the log.
133
133
Message that need to log at debug level.
134
134
. PARAMETER SkipEmptyLine
135
135
Whether to skip empty line.
136
+ . PARAMETER PassThru
137
+ Return the message. By default, this function does not generate any output.
136
138
. OUTPUTS
137
- [Void]
139
+ [String] When use the parameter `PassThru`, this function return the message.
140
+ [Void] By default, this function does not generate any output.
138
141
#>
139
142
Function Write-Debug {
140
143
[CmdletBinding (HelpUri = ' https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_writegithubactionsdebug' )]
141
- [OutputType ([ Void ])]
144
+ [OutputType (([ String ] , [ Void ]) )]
142
145
Param (
143
146
[Parameter (Mandatory = $True , Position = 0 , ValueFromPipeline = $True , ValueFromPipelineByPropertyName = $True )][AllowEmptyString ()][AllowNull ()][Alias (' Content' )][String ]$Message ,
144
- [Alias (' NoEmptyLine' )][Switch ]$SkipEmptyLine
147
+ [Alias (' NoEmptyLine' )][Switch ]$SkipEmptyLine ,
148
+ [Switch ]$PassThru
145
149
)
146
150
Process {
147
151
If (
@@ -283,28 +287,39 @@ Print anything to the log without accidentally execute any stdout command.
283
287
Item that need to log.
284
288
. PARAMETER GroupTitle
285
289
Title of the log group; This creates an expandable group in the log, and anything are inside this expandable group in the log.
290
+ . PARAMETER WriteIf
291
+ Log item based on specify condition.
292
+ . PARAMETER PassThru
293
+ Return the item. By default, this function does not generate any output.
286
294
. OUTPUTS
287
- [Void]
295
+ [Unknown] When use the parameter `PassThru`, this function return the item.
296
+ [Void] By default, this function does not generate any output.
288
297
#>
289
298
Function Write-Raw {
290
299
[CmdletBinding (HelpUri = ' https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_writegithubactionsraw' )]
291
- [OutputType ([Void ])]
292
300
Param (
293
301
[Parameter (Mandatory = $True , Position = 0 , ValueFromPipeline = $True , ValueFromPipelineByPropertyName = $True )][AllowEmptyCollection ()][AllowEmptyString ()][AllowNull ()][Alias (' Content' , ' Input' , ' Message' , ' Object' )]$InputObject ,
294
- [Alias (' GroupHeader' , ' Header' , ' Title' )][String ]$GroupTitle
302
+ [Alias (' GroupHeader' , ' Header' , ' Title' )][String ]$GroupTitle ,
303
+ [Boolean ]$WriteIf = $True ,
304
+ [Switch ]$PassThru
295
305
)
296
306
Begin {
297
- If ($GroupTitle.Length -gt 0 ) {
307
+ If ($WriteIf -and $ GroupTitle.Length -gt 0 ) {
298
308
Enter-LogGroup - Title $GroupTitle
299
309
}
300
310
[String ]$EndToken = Disable-GitHubActionsStdOutCommandProcess
301
311
}
302
312
Process {
303
- Write-Host - Object $InputObject
313
+ If ($WriteIf ) {
314
+ Write-Host - Object $InputObject
315
+ }
316
+ If ($PassThru.IsPresent ) {
317
+ Write-Output - InputObject $InputObject
318
+ }
304
319
}
305
320
End {
306
321
Enable-GitHubActionsStdOutCommandProcess - EndToken $EndToken
307
- If ($GroupTitle.Length -gt 0 ) {
322
+ If ($WriteIf -and $ GroupTitle.Length -gt 0 ) {
308
323
Exit-LogGroup
309
324
}
310
325
}
0 commit comments