PowerShell_Scripts/docker/dcreup.ps1

38 lines
1.6 KiB
PowerShell

[CmdletBinding(SupportsShouldProcess)]param(
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeDirsCompleter -ArgumentList $args})]
[string[]]$ProjectPath,
[switch]$Recurse,
[int]$Depth=1,
[switch]$NoLogs,
[switch]$NoPull,
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('pull'))})]
[array]$PullParams,
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('logs'))})]
[array]$LogsParams,
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('up'))})]
[array]$UpParams=@('-d','--remove-orphans'),
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('up'))})]
[array]$Containers
)
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)) }
$UpParams[0] = @('--force-recreate') + $UpParams[0]
$local:passParams = [ordered]@{
ProjectPath=$ProjectPath
Recurse=$Recurse
Depth=$Depth
NoLogs=$NoLogs
NoPull=$NoPull
PullParams=$PullParams
LogsParams=$LogsParams
UpParams=$UpParams
Containers=$Containers
}
dcup @passParams