@@ -133,15 +133,19 @@ Print a debug message to the log.
133133Message that need to log at debug level.
134134. PARAMETER SkipEmptyLine
135135Whether to skip empty line.
136+ . PARAMETER PassThru
137+ Return the message. By default, this function does not generate any output.
136138. 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.
138141#>
139142Function Write-Debug {
140143 [CmdletBinding (HelpUri = ' https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_writegithubactionsdebug' )]
141- [OutputType ([ Void ])]
144+ [OutputType (([ String ] , [ Void ]) )]
142145 Param (
143146 [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
145149 )
146150 Process {
147151 If (
@@ -283,28 +287,39 @@ Print anything to the log without accidentally execute any stdout command.
283287Item that need to log.
284288. PARAMETER GroupTitle
285289Title 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.
286294. 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.
288297#>
289298Function Write-Raw {
290299 [CmdletBinding (HelpUri = ' https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_writegithubactionsraw' )]
291- [OutputType ([Void ])]
292300 Param (
293301 [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
295305 )
296306 Begin {
297- If ($GroupTitle.Length -gt 0 ) {
307+ If ($WriteIf -and $ GroupTitle.Length -gt 0 ) {
298308 Enter-LogGroup - Title $GroupTitle
299309 }
300310 [String ]$EndToken = Disable-GitHubActionsStdOutCommandProcess
301311 }
302312 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+ }
304319 }
305320 End {
306321 Enable-GitHubActionsStdOutCommandProcess - EndToken $EndToken
307- If ($GroupTitle.Length -gt 0 ) {
322+ If ($WriteIf -and $ GroupTitle.Length -gt 0 ) {
308323 Exit-LogGroup
309324 }
310325 }
0 commit comments