From 15f78417b94c75db15d9db5028c3711f5eada58f Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Mon, 20 Nov 2017 13:19:31 +0100 Subject: [PATCH] Add bash completion for `--platform` Signed-off-by: Harald Albers --- contrib/completion/bash/docker | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index e8a88348ea..41a4ae4a40 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1768,6 +1768,9 @@ _docker_container_run_and_create() { --io-maxiops --isolation " + __docker_daemon_is_experimental && options_with_args+=" + --platform + " local boolean_options=" --disable-content-trust=false @@ -2472,10 +2475,15 @@ _docker_image_build() { --quiet -q --rm " - __docker_daemon_is_experimental && boolean_options+=" - --squash - --stream - " + if __docker_daemon_is_experimental ; then + options_with_args+=" + --platform + " + boolean_options+=" + --squash + --stream + " + fi local all_options="$options_with_args $boolean_options" @@ -2687,12 +2695,21 @@ _docker_image_prune() { } _docker_image_pull() { + case "$prev" in + --platform) + return + ;; + esac + case "$cur" in -*) - COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help" -- "$cur" ) ) + local options="--all-tags -a --disable-content-trust=false --help" + __docker_daemon_is_experimental && options+=" --platform" + + COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) ;; *) - local counter=$(__docker_pos_first_nonflag) + local counter=$(__docker_pos_first_nonflag --platform) if [ "$cword" -eq "$counter" ]; then for arg in "${COMP_WORDS[@]}"; do case "$arg" in