PowerShell_Scripts/docker/dcreup.ps1

38 lines
1.6 KiB
PowerShell
Raw Normal View History

[CmdletBinding(SupportsShouldProcess)]param(
2021-03-23 01:06:49 -04:00
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeDirsCompleter -ArgumentList $args})]
[string[]]$ProjectPath,
[switch]$Recurse,
[int]$Depth=1,
[switch]$NoLogs,
[switch]$NoPull,
2021-03-23 01:06:49 -04:00
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('pull'))})]
[array]$PullParams,
2021-03-23 01:06:49 -04:00
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('logs'))})]
[array]$LogsParams,
2021-03-23 01:06:49 -04:00
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeCompleter -ArgumentList ($args+@('up'))})]
[array]$UpParams=@('-d','--remove-orphans'),
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
2021-03-23 01:06:49 -04:00
[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