From 5e76d5a0ba4b36cfa3e11a9f07607581c8f9bc62 Mon Sep 17 00:00:00 2001 From: lksz Date: Thu, 23 Sep 2021 21:56:01 -0400 Subject: [PATCH] dcsw defaults to nochange, dcl fixed --- docker/Switch-DockerCompose.ps1 | 31 +++++++++++++++++++++---------- docker/dcl.ps1 | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docker/Switch-DockerCompose.ps1 b/docker/Switch-DockerCompose.ps1 index 22f9c53..5af4334 100644 --- a/docker/Switch-DockerCompose.ps1 +++ b/docker/Switch-DockerCompose.ps1 @@ -3,8 +3,8 @@ [switch]$On, [Parameter(ParameterSetName="Off",Mandatory)] [switch]$Off, - [Parameter(ParameterSetName="Query",Mandatory)] - [switch]$NoChange, + [Parameter(ParameterSetName="Toggle",Mandatory)] + [switch]$Toggle, [switch]$Recurse, [int]$Depth=1, [Parameter(ParameterSetName="On",Position = 0, ValueFromRemainingArguments)] @@ -42,24 +42,35 @@ $ProjectPath | ForEach-Object { } if( -not $dcPathList ) { return } +$local:QueryOnly = -not $On -and -not $Off -and -not $Toggle + $dcPathList | ForEach-Object { + $local:name = "$_" + if( $PWD -like $name ) { + $name = Split-Path -Leaf $name + } else { + $name = $($name.Replace($PWD.Path,'').Substring(1)) + } + $local:NoAutoPath = $(Join-Path $_ '.noauto.all') $local:NoAutoOffPath = "${NoAutoPath}.off" - $local:IsNoAuto = Test-Path $NoAutoPath - $local:IsNoAutoOff = Test-Path $NoAutoOffPath + $local:IsOff = Test-Path $NoAutoPath + $local:IsExplicitOn = Test-Path $NoAutoOffPath - if( ($NoChange -and $IsNoAuto) -or (-not $NoChange -and ($Off -or (-not $On -and -not $IsNoAuto)) ) ) { - if( $IsNoAutoOff ) { + $local:SetOff = $Off -or ($Toggle -and -not $IsOff) + $local:SetOn = $On -or ($Toggle -and $IsOff) + if( ($QueryOnly -and $IsOff) -or (-not $QueryOnly -and $SetOff) ) { + if( -not $QueryOnly -and $IsExplicitOn ) { Move-Item $NoAutoOffPath $NoAutoPath - } elseif( -not $IsNoAuto -and -not $NoChange ) { + } elseif( -not $QueryOnly -and -not $IsOff ) { $null = New-Item -ItemType File -Path $NoAutoPath -Value "" } Write-Host -ForegroundColor Magenta -NoNewline "Off" - } elseif( $NoChange -or $On -or (-not $Off -and $IsNoAuto) ) { - if( $IsNoAuto -and -not $NoChange ) { + } elseif( ($QueryOnly -and -not $IsOff) -or (-not $QueryOnly -and $SetOn) ) { + if( -not $QueryOnly -and $IsOff ) { Move-Item $NoAutoPath $NoAutoOffPath } Write-Host -ForegroundColor Gree -NoNewline "On " } - Write-Host -ForegroundColor Cyan " $("$_".Replace($PWD.Path,'').Substring(1))" + Write-Host -ForegroundColor Cyan " $name" } diff --git a/docker/dcl.ps1 b/docker/dcl.ps1 index c7f2947..8202024 100644 --- a/docker/dcl.ps1 +++ b/docker/dcl.ps1 @@ -7,6 +7,6 @@ ) if( -not $CliParams -or $CliParams[0] -is [string] ) { $CliParams = @($CliParams,@($null)) } -$CliParams[0] = @('logs','--tail=40','follow') + $CliParams[0] +$CliParams[0] = @('logs','--tail=40','--follow') + $CliParams[0] Invoke-DockerCompose -ProjectPath $ProjectPath -CliParams $CliParams