2020-11-11 21:38:56 +00:00
|
|
|
[CmdletBinding(SupportsShouldProcess)]param(
|
2021-03-23 05:06:49 +00:00
|
|
|
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeDirsCompleter -ArgumentList $args})]
|
2021-01-15 06:15:54 +00:00
|
|
|
[string[]]$ProjectPath,
|
|
|
|
[switch]$Recurse,
|
|
|
|
[int]$Depth=1,
|
|
|
|
[switch]$NoLogs,
|
|
|
|
[switch]$NoPull,
|
2021-03-23 05:06:49 +00:00
|
|
|
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('pull'))})]
|
2021-01-15 06:15:54 +00:00
|
|
|
[array]$PullParams,
|
2021-03-23 05:06:49 +00:00
|
|
|
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('logs'))})]
|
2021-01-15 06:15:54 +00:00
|
|
|
[array]$LogsParams,
|
2021-03-23 05:06:49 +00:00
|
|
|
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('up'))})]
|
2021-02-18 15:53:32 +00:00
|
|
|
[array]$UpParams=@('--detach','--remove-orphans'),
|
2020-11-11 21:38:56 +00:00
|
|
|
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
2021-03-23 05:06:49 +00:00
|
|
|
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('up'))})]
|
2021-01-15 06:15:54 +00:00
|
|
|
[array]$Containers
|
2020-11-11 21:38:56 +00:00
|
|
|
)
|
2020-10-31 21:10:32 +00:00
|
|
|
|
2021-01-15 06:15:54 +00:00
|
|
|
$local:ForceNoFollow = $false
|
|
|
|
if( -not $ProjectPath ) {
|
|
|
|
$ProjectPath=@($PWD)
|
|
|
|
$ForceNoFollow = $Recurse
|
|
|
|
|
|
|
|
} elseif( -not $NoLogs ) {
|
|
|
|
$ForceNoFollow=$($ProjectPath.Length -gt 1)
|
2020-10-31 21:10:32 +00:00
|
|
|
}
|
2021-01-13 06:02:37 +00:00
|
|
|
|
2021-01-15 06:15:54 +00:00
|
|
|
if( -not $Containers -or ($Containers[0] -is [string]) ) { $Containers = @($Containers,@($null)) }
|
|
|
|
if( -not $UpParams -or ($UpParams[0] -is [string]) ) { $UpParams = @($UpParams,@($null)) }
|
|
|
|
if( -not $PullParams -or ($PullParams[0] -is [string]) ) { $PullParams = @($PullParams,@($null)) }
|
|
|
|
if( -not $LogsParams -or ($LogsParams[0] -is [string]) ) { $LogsParams = @($LogsParams,@($null)) }
|
|
|
|
|
|
|
|
if( -not $LogsParams[0] ) {
|
|
|
|
$local:tailLen = 10
|
|
|
|
$logsParams[0] = @()
|
|
|
|
if( -not $ForceNoFollow ) {
|
|
|
|
$tailLen = 40
|
|
|
|
$logsParams[0] += @('--follow')
|
|
|
|
}
|
|
|
|
$logsParams[0] += @("--tail=$tailLen")
|
2020-11-11 21:38:56 +00:00
|
|
|
}
|
|
|
|
|
2021-02-18 15:53:32 +00:00
|
|
|
$local:moreParams = @()
|
|
|
|
#if( $ForceNoFollow ) { $moreParams = @('--no-color', '--quiet-pull') }
|
2021-02-22 19:58:49 +00:00
|
|
|
$PullParams[0] = @('&', 'pull' ) + $PullParams[0] + $Containers
|
|
|
|
#if( $ForceNoFollow ) { $PullParams[0] = @('&') + $PullParams[0] }
|
|
|
|
$UpParams[0] = @('&', 'up' ) + $UpParams[0] + $Containers
|
|
|
|
#if( $ForceNoFollow ) { $UpParams[0] = @('&') + $UpParams[0] }
|
2021-02-04 01:03:39 +00:00
|
|
|
$LogsParams[0] = @('logs' ) + $LogsParams[0] + $Containers
|
2021-01-15 06:15:54 +00:00
|
|
|
|
2021-01-15 06:56:10 +00:00
|
|
|
if( -not $NoPull ) { $allParams += $PullParams + @(@('!')) }
|
|
|
|
$local:allParams += $UpParams
|
2021-01-15 06:15:54 +00:00
|
|
|
if( -not $NoLogs ) { $allParams += @(@('!')) + $LogsParams }
|
|
|
|
|
|
|
|
Invoke-DockerCompose -ProjectPath $ProjectPath -CliParams $allParams -Recurse:$Recurse -Depth $Depth
|