[CmdletBinding(SupportsShouldProcess)]param( [ArgumentCompleter({ param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters ) [DockerComposeDirs]::_GetValidValues($wordToComplete,$true) })] [string[]]$ProjectPath=@($PWD), [switch]$Force, [string[]]$AdditionalFiles ) $local:EditCandidates = @('docker-compose.###','.base.docker-compose.###') $local:EditBonus = @('Dockerfile', '.env', '*.env') $local:editFiles = @() foreach( $local:ext in @('.yml', '.yaml') ) { $local:rawEditCandidates = $EditCandidates | ForEach-Object { $_ -replace '\.###',$ext } foreach( $local:fileName in $rawEditCandidates ) { foreach( $local:path in $ProjectPath ) { $local:testPath = Join-Path $path $fileName if( $Force -or $(Test-Path $testPath) ) { $editFiles += $testPath $editFiles += Get-ChildItem $(Join-Path $path '*') -Include $EditBonus -Depth 1 } } } if( -not $editFiles ) { continue } break } Edit-TextFile ($($editFiles | Sort-Object) + $AdditionalFiles) $editFiles | Select-Object -First 1 | ForEach-Object { docker-compose --file $(Resolve-Path $_) config -q }