Merge pull request #413 from albers/completion-build--target

Add bash completion for `docker build --target`
This commit is contained in:
Tõnis Tiigi 2017-08-07 12:41:03 -07:00 committed by GitHub
commit 227e042ff0
1 changed files with 14 additions and 0 deletions

View File

@ -2444,6 +2444,7 @@ _docker_image_build() {
--network
--shm-size
--tag -t
--target
--ulimit
"
__docker_daemon_os_is windows && options_with_args+="
@ -2510,6 +2511,19 @@ _docker_image_build() {
__docker_complete_image_repos_and_tags
return
;;
--target)
local context_pos=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" )
local context="${words[$context_pos]}"
context="${context:-.}"
local file="$( __docker_value_of_option '--file|f' )"
local default_file="${context%/}/Dockerfile"
local dockerfile="${file:-$default_file}"
local targets="$( sed -n 's/^FROM .\+ AS \(.\+\)/\1/p' "$dockerfile" 2>/dev/null )"
COMPREPLY=( $( compgen -W "$targets" -- "$cur" ) )
return
;;
$(__docker_to_extglob "$options_with_args") )
return
;;