This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/tests/examplefiles/powershell/Get-CommandDefinitionHtml.ps1
Oleh Prypin 6f43092173
Also add auto-updatable output-based tests to examplefiles (#1689)
Co-authored-by: Georg Brandl <georg@python.org>
2021-01-20 10:48:45 +01:00

66 lines
1.3 KiB
PowerShell

function Get-CommandDefinitionHtml {
# this tells powershell to allow advanced features,
# like the [validatenotnullorempty()] attribute below.
[CmdletBinding()]
param(
[ValidateNotNullOrEmpty()]
[string]$name
)
$command = get-command $name
# Look mom! I'm a cmdlet!
$PSCmdlet.WriteVerbose("Dumping HTML for " + $command)
@"
<html>
<head>
<title>$($command.name)</title>
</head>
<body>
<table border="1">
$(
$command.parametersets | % {
@"
<tr>
<td>$($_.name)</td>
<td>
<table border="1">
<tr>
<th colspan="8">Parameters</th>
$(
$count = 0
$_.parameters | % {
if (0 -eq ($count % 8)) {
@'
</tr>
<tr>
'@
}
@"
<td>$($_.name)</td>
"@
$count++
}
)
</tr>
</table>
</td>
</tr>
"@
}
)
</table>
</body>
</html>
"@
}
Get-CommandDefinitionHtml get-item > out.html
# show in browser
invoke-item out.html