docs: fix make.ps1 hanging when Out-String wraps help on narrow consoles

Out-String breaks long help lines on smaller consoles (such as CI
runners), so command discovery mis-parses wrapped description text
as subcommands and docs can recurse forever. Parse as remote-docs.sh

Signed-off-by: Gunjan Vyas <gvyas@redhat.com>
This commit is contained in:
Gunjan Vyas 2026-07-22 17:50:43 +05:30
parent c0fb461475
commit 8fd4c47dfd

View file

@ -14,32 +14,47 @@ function Get-Podman-Commands-List{
Write-Host "Retrieving the list of ""podman"" commands."
}
$helpLines = @(Invoke-Expression "$podmanClient $podmanHelpCommand")
# Retrieve the list of subcommands of $command
# e.g. "podman help machine" returns the list of
# "podman machine" subcommands: info, init, etc...
$subCommands = @()
$subCommands = Invoke-Expression "$podmanClient $podmanHelpCommand" |
Select-String -Pattern "^\s*Available Commands:" -Context 0, 1000 | Out-String -Stream |
Select-String -Pattern "^\s+$" -Context 1000, 0 | Out-String -Stream |
Select-String -Pattern ">\s*Available Commands:|^>\s*$|^\s*$" -NotMatch | Out-String -Stream |
ForEach-Object { $_ -replace '^\s*(\w+)\s+.*$', '$1' } | Where-Object { $_ -ne "" }
if ($command) {
$subCommands = $subCommands | ForEach-Object { "$command $_" }
}
# Recursively get the list of sub-subcommands for each subcommand
foreach ($subCommand in $subCommands) {
$subSubCommands = @()
$subSubCommands = Get-Podman-Commands-List -podmanClient "$podmanClient" -command "${subCommand}"
if ($subSubCommands) {
$subCommands += $subSubCommands
$inCommands = $false
foreach ($line in $helpLines) {
if ($line -match "^\s*Available Commands:\s*$") {
$inCommands = $true
continue
}
# end of commands list
if ($inCommands -and $line -match '^\s*Options:\s*$') {
break
}
if (!$inCommands) {
continue
}
# add command to list
$name = ($line.Trim() -Split '\s+')[0]
if ($name -and $name -ne 'help') {
$subCommands += $name
}
}
return $subCommands
if ($command) {
$subCommands = @($subCommands | ForEach-Object { "$command $_" })
} else {
$subCommands = @($subCommands)
}
$allCommands = @($subCommands)
foreach ($subCommand in $subCommands) {
$subSubCommands = @(Get-Podman-Commands-List -podmanClient "$podmanClient" -command "${subCommand}")
if ($subSubCommands) {
$allCommands += $subSubCommands
}
}
return $allCommands
}
function Build-Podman-For-Windows-HTML-Page{