=dcsw additional output

This commit is contained in:
Szkolnik Media Master 2021-11-29 17:00:43 -05:00
parent c8b9f5d2dc
commit c2675e2346
6 changed files with 202 additions and 8 deletions

View file

@ -31,8 +31,7 @@ $ProjectPath | ForEach-Object {
$gciParams.Depth = $Depth
}
$dcPathList += Get-ChildItem -Path $_ -Include "docker-compose$ext" @gciParams |
Select-Object -ExpandProperty Directory # |
# Where-Object { $Force -or -not (Test-Path $(Join-Path $_ .noauto.all)) }
Select-Object -ExpandProperty Directory
}
if( ($dcPathList -and -not $Recure) -or $ext -eq '.yaml' ) {
break
@ -46,6 +45,16 @@ $local:QueryOnly = -not $On -and -not $Off -and -not $Toggle
$dcPathList | ForEach-Object {
$local:name = "$_"
$local:c = Get-Content -Head 3 (Join-Path $_ "docker-compose$ext")
$local:r = [ordered]@{
Dir = Split-Path -Leaf $_
State = ""
Version = ($c[0] -replace 'Version: ','' -replace "[`"']",'').Trim()
Stack = "?"
}
if( $c[1] -match "^# stack(?:\W*): ?(\w+)\W*$" ) { $r.Stack = $matches[1] }
if( $c[2] -match "^# ports prefix: ([\dx#]{4,5})" ) { $r.Stack = $matches[1] + " | " + $r.Stack }
if( $PWD -like $name ) {
$name = Split-Path -Leaf $name
} else {
@ -65,12 +74,16 @@ $dcPathList | ForEach-Object {
} elseif( -not $QueryOnly -and -not $IsOff ) {
$null = New-Item -ItemType File -Path $NoAutoPath -Value ""
}
Write-Host -ForegroundColor Magenta -NoNewline "Off"
# Write-Host -ForegroundColor Magenta -NoNewline "Off"
$r.State = "Off"
} elseif( ($QueryOnly -and -not $IsOff) -or (-not $QueryOnly -and $SetOn) ) {
if( -not $QueryOnly -and $IsOff ) {
Move-Item $NoAutoPath $NoAutoOffPath
}
Write-Host -ForegroundColor Green -NoNewline "On "
# Write-Host -ForegroundColor Green -NoNewline "On "
$r.State = "On"
}
Write-Host -ForegroundColor Cyan " $name"
# Write-Host -ForegroundColor Cyan " $name"
[PSCustomObject]$r
}