forked from StartAutomating/PSDevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trace-GitCommand.ps1
48 lines (46 loc) · 1.55 KB
/
Trace-GitCommand.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function Trace-GitCommand
{
<#
.Synopsis
Traces information into GitHub Workflow Output
.Description
Traces information about a command as a debug message in a GitHub workflow.
.Example
Trace-GitCommand -Command Get-Process -Parameter @{id=$pid}
.Example
$myInvocation | Trace-GitCommand
.Link
Write-GitDebug
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "", Justification="Directly outputs in certain scenarios")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("Test-ForUnusableFunction", "", Justification="Directly outputs in certain scenarios")]
[OutputType([string])]
param(
# The command line.
[Parameter(Mandatory,ParameterSetName='Command',ValueFromPipelineByPropertyName)]
[Alias('MyCommand','Line')]
[string]
$Command,
# A dictionary of parameters to the command.
[Parameter(ParameterSetName='Command',ValueFromPipelineByPropertyName)]
[Alias('Parameters', 'BoundParameters')]
[Collections.IDictionary]
$Parameter
)
process {
if ($Command) {
#region Write Debug Message
Write-GitDebug -Message (
$Command + ' ' + @(
if ($Parameter) {
foreach ($kv in $Parameter.GetEnumerator()) {
'-' + $kv.Key
$kv.Value
}
}
) -join ' '
)
#endregion Write Debug Message
}
}
}