mirror of https://github.com/docker/cli.git
Add shellcheck for bash completion
Signed-off-by: Jean-Pierre Huynh <jean-pierre.huynh@ounet.fr>
This commit is contained in:
parent
e3746d388e
commit
b2fc35aefa
5
Makefile
5
Makefile
|
@ -54,6 +54,11 @@ manpages:
|
||||||
yamldocs:
|
yamldocs:
|
||||||
scripts/docs/generate-yaml.sh
|
scripts/docs/generate-yaml.sh
|
||||||
|
|
||||||
|
## Shellcheck validation
|
||||||
|
.PHONY: shellcheck
|
||||||
|
shellcheck:
|
||||||
|
scripts/validate/shellcheck
|
||||||
|
|
||||||
cli/compose/schema/bindata.go: cli/compose/schema/data/*.json
|
cli/compose/schema/bindata.go: cli/compose/schema/data/*.json
|
||||||
go generate github.com/docker/cli/cli/compose/schema
|
go generate github.com/docker/cli/cli/compose/schema
|
||||||
|
|
||||||
|
|
16
circle.yml
16
circle.yml
|
@ -91,7 +91,20 @@ jobs:
|
||||||
docker build -f $dockerfile --tag cli-builder-with-git:$CIRCLE_BUILD_NUM .
|
docker build -f $dockerfile --tag cli-builder-with-git:$CIRCLE_BUILD_NUM .
|
||||||
docker run --rm cli-builder-with-git:$CIRCLE_BUILD_NUM \
|
docker run --rm cli-builder-with-git:$CIRCLE_BUILD_NUM \
|
||||||
make -B vendor compose-jsonschema manpages yamldocs
|
make -B vendor compose-jsonschema manpages yamldocs
|
||||||
|
shellcheck:
|
||||||
|
working_directory: /work
|
||||||
|
docker: [{image: 'docker:17.05-git'}]
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- setup_remote_docker
|
||||||
|
- run:
|
||||||
|
name: "Run shellcheck"
|
||||||
|
command: |
|
||||||
|
dockerfile=dockerfiles/Dockerfile.validate
|
||||||
|
echo "COPY . ." >> $dockerfile
|
||||||
|
docker build -f $dockerfile --tag cli-validator:$CIRCLE_BUILD_NUM .
|
||||||
|
docker run --rm cli-validator:$CIRCLE_BUILD_NUM \
|
||||||
|
make -B shellcheck
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
ci:
|
ci:
|
||||||
|
@ -100,3 +113,4 @@ workflows:
|
||||||
- cross
|
- cross
|
||||||
- test
|
- test
|
||||||
- validate
|
- validate
|
||||||
|
- shellcheck
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC2155
|
||||||
|
#
|
||||||
|
# Shellcheck ignore list:
|
||||||
|
# - SC2155: Declare and assign separately to avoid masking return values.
|
||||||
#
|
#
|
||||||
# bash completion file for core docker commands
|
# bash completion file for core docker commands
|
||||||
#
|
#
|
||||||
|
@ -142,6 +146,7 @@ __docker_images() {
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local repo_print_command
|
local repo_print_command
|
||||||
|
# shellcheck disable=SC2016
|
||||||
if [ "${DOCKER_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then
|
if [ "${DOCKER_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then
|
||||||
repo_print_command='print $1; print $1":"$2'
|
repo_print_command='print $1; print $1":"$2'
|
||||||
else
|
else
|
||||||
|
@ -149,6 +154,7 @@ __docker_images() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local awk_script
|
local awk_script
|
||||||
|
# shellcheck disable=SC2016
|
||||||
case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
|
case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
|
||||||
all|non-intermediate)
|
all|non-intermediate)
|
||||||
awk_script='NR>1 { print $3; if ($1 != "<none>") { '"$repo_print_command"' } }'
|
awk_script='NR>1 { print $3; if ($1 != "<none>") { '"$repo_print_command"' } }'
|
||||||
|
@ -213,6 +219,7 @@ __docker_complete_networks() {
|
||||||
COMPREPLY=( $(compgen -W "$(__docker_networks "$@")" -- "$current") )
|
COMPREPLY=( $(compgen -W "$(__docker_networks "$@")" -- "$current") )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# shellcheck disable=SC2016,SC2128,SC2178
|
||||||
__docker_complete_containers_in_network() {
|
__docker_complete_containers_in_network() {
|
||||||
local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1")
|
local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1")
|
||||||
COMPREPLY=( $(compgen -W "$containers" -- "$cur") )
|
COMPREPLY=( $(compgen -W "$containers" -- "$cur") )
|
||||||
|
@ -271,6 +278,7 @@ __docker_plugins_bundled() {
|
||||||
for del in "${remove[@]}" ; do
|
for del in "${remove[@]}" ; do
|
||||||
plugins=(${plugins[@]/$del/})
|
plugins=(${plugins[@]/$del/})
|
||||||
done
|
done
|
||||||
|
# shellcheck disable=SC2145
|
||||||
echo "${plugins[@]} ${add[@]}"
|
echo "${plugins[@]} ${add[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,6 +397,7 @@ __docker_complete_stacks() {
|
||||||
# output to the IDs or names of matching items. This setting takes
|
# output to the IDs or names of matching items. This setting takes
|
||||||
# precedence over the environment setting.
|
# precedence over the environment setting.
|
||||||
# Completions may be added with `--add`, e.g. `--add self`.
|
# Completions may be added with `--add`, e.g. `--add self`.
|
||||||
|
# shellcheck disable=SC2016
|
||||||
__docker_nodes() {
|
__docker_nodes() {
|
||||||
local add=()
|
local add=()
|
||||||
local fields='$2' # default: node name only
|
local fields='$2' # default: node name only
|
||||||
|
@ -414,7 +423,7 @@ __docker_nodes() {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echo $(__docker_q node ls "$@" | tr -d '*' | awk "NR>1 {print $fields}") "${add[@]}"
|
echo "$(__docker_q node ls "$@" | tr -d '*' | awk "NR>1 {print $fields}")" "${add[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# __docker_complete_nodes applies completion of nodes based on the current
|
# __docker_complete_nodes applies completion of nodes based on the current
|
||||||
|
@ -437,6 +446,7 @@ __docker_complete_nodes() {
|
||||||
# An optional first option `--id|--name` may be used to limit the
|
# An optional first option `--id|--name` may be used to limit the
|
||||||
# output to the IDs or names of matching items. This setting takes
|
# output to the IDs or names of matching items. This setting takes
|
||||||
# precedence over the environment setting.
|
# precedence over the environment setting.
|
||||||
|
# shellcheck disable=SC2016
|
||||||
__docker_services() {
|
__docker_services() {
|
||||||
local fields='$2' # default: service name only
|
local fields='$2' # default: service name only
|
||||||
[ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name
|
[ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name
|
||||||
|
@ -509,7 +519,7 @@ __docker_pos_first_nonflag() {
|
||||||
local argument_flags=$1
|
local argument_flags=$1
|
||||||
|
|
||||||
local counter=$((${subcommand_pos:-${command_pos}} + 1))
|
local counter=$((${subcommand_pos:-${command_pos}} + 1))
|
||||||
while [ $counter -le $cword ]; do
|
while [ "$counter" -le "$cword" ]; do
|
||||||
if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then
|
if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then
|
||||||
(( counter++ ))
|
(( counter++ ))
|
||||||
# eat "=" in case of --option=arg syntax
|
# eat "=" in case of --option=arg syntax
|
||||||
|
@ -569,10 +579,10 @@ __docker_value_of_option() {
|
||||||
local option_extglob=$(__docker_to_extglob "$1")
|
local option_extglob=$(__docker_to_extglob "$1")
|
||||||
|
|
||||||
local counter=$((command_pos + 1))
|
local counter=$((command_pos + 1))
|
||||||
while [ $counter -lt $cword ]; do
|
while [ "$counter" -lt "$cword" ]; do
|
||||||
case ${words[$counter]} in
|
case ${words[$counter]} in
|
||||||
$option_extglob )
|
$option_extglob )
|
||||||
echo ${words[$counter + 1]}
|
echo "${words[$counter + 1]}"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -609,14 +619,14 @@ __docker_to_extglob() {
|
||||||
__docker_subcommands() {
|
__docker_subcommands() {
|
||||||
local subcommands="$1"
|
local subcommands="$1"
|
||||||
|
|
||||||
local counter=$(($command_pos + 1))
|
local counter=$((command_pos + 1))
|
||||||
while [ $counter -lt $cword ]; do
|
while [ "$counter" -lt "$cword" ]; do
|
||||||
case "${words[$counter]}" in
|
case "${words[$counter]}" in
|
||||||
$(__docker_to_extglob "$subcommands") )
|
$(__docker_to_extglob "$subcommands") )
|
||||||
subcommand_pos=$counter
|
subcommand_pos=$counter
|
||||||
local subcommand=${words[$counter]}
|
local subcommand=${words[$counter]}
|
||||||
local completions_func=_docker_${command}_${subcommand//-/_}
|
local completions_func=_docker_${command}_${subcommand//-/_}
|
||||||
declare -F $completions_func >/dev/null && $completions_func
|
declare -F "$completions_func" >/dev/null && "$completions_func"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -951,7 +961,7 @@ __docker_complete_signals() {
|
||||||
SIGUSR1
|
SIGUSR1
|
||||||
SIGUSR2
|
SIGUSR2
|
||||||
)
|
)
|
||||||
COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) )
|
COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo "$cur" | tr '[:lower:]' '[:upper:]')" ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
__docker_complete_user_group() {
|
__docker_complete_user_group() {
|
||||||
|
@ -991,7 +1001,7 @@ _docker_docker() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" )
|
local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" )
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_daemon_is_experimental && commands+=(${experimental_commands[*]})
|
__docker_daemon_is_experimental && commands+=(${experimental_commands[*]})
|
||||||
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
|
||||||
fi
|
fi
|
||||||
|
@ -1044,7 +1054,7 @@ _docker_checkpoint_create() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
|
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_running
|
__docker_complete_containers_running
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1065,7 +1075,7 @@ _docker_checkpoint_ls() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
|
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1086,9 +1096,9 @@ _docker_checkpoint_rm() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
|
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
elif [ $cword -eq $(($counter + 1)) ]; then
|
elif [ "$cword" -eq "$((counter + 1))" ]; then
|
||||||
COMPREPLY=( $( compgen -W "$(__docker_q checkpoint ls "$prev" | sed 1d)" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$(__docker_q checkpoint ls "$prev" | sed 1d)" -- "$cur" ) )
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1149,7 +1159,7 @@ _docker_container_attach() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--detach-keys')
|
local counter=$(__docker_pos_first_nonflag '--detach-keys')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_running
|
__docker_complete_containers_running
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1170,13 +1180,13 @@ _docker_container_commit() {
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--author|-a|--change|-c|--message|-m')
|
local counter=$(__docker_pos_first_nonflag '--author|-a|--change|-c|--message|-m')
|
||||||
|
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
(( counter++ ))
|
(( counter++ ))
|
||||||
|
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_image_repos_and_tags
|
__docker_complete_image_repos_and_tags
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -1191,7 +1201,7 @@ _docker_container_cp() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
*:)
|
*:)
|
||||||
return
|
return
|
||||||
|
@ -1206,6 +1216,7 @@ _docker_container_cp() {
|
||||||
local containers=( ${COMPREPLY[@]} )
|
local containers=( ${COMPREPLY[@]} )
|
||||||
|
|
||||||
COMPREPLY=( $( compgen -W "${files[*]} ${containers[*]}" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "${files[*]} ${containers[*]}" -- "$cur" ) )
|
||||||
|
# shellcheck disable=SC2128
|
||||||
if [[ "$COMPREPLY" == *: ]]; then
|
if [[ "$COMPREPLY" == *: ]]; then
|
||||||
__docker_nospace
|
__docker_nospace
|
||||||
fi
|
fi
|
||||||
|
@ -1215,7 +1226,7 @@ _docker_container_cp() {
|
||||||
fi
|
fi
|
||||||
(( counter++ ))
|
(( counter++ ))
|
||||||
|
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
if [ -e "$prev" ]; then
|
if [ -e "$prev" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
|
COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
|
||||||
|
@ -1240,7 +1251,7 @@ _docker_container_diff() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1252,7 +1263,7 @@ _docker_container_exec() {
|
||||||
|
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
--env|-e)
|
--env|-e)
|
||||||
# we do not append a "=" here because "-e VARNAME" is legal systax, too
|
# we do not append a "=" here because "-e VARNAME" is legal syntax, too
|
||||||
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
||||||
__docker_nospace
|
__docker_nospace
|
||||||
return
|
return
|
||||||
|
@ -1287,7 +1298,7 @@ _docker_container_export() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1329,7 +1340,7 @@ _docker_container_logs() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--since|--tail')
|
local counter=$(__docker_pos_first_nonflag '--since|--tail')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1425,7 +1436,7 @@ _docker_container_port() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1459,7 +1470,7 @@ _docker_container_rename() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1497,7 +1508,7 @@ _docker_container_rm() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
__docker_complete_containers_removable
|
__docker_complete_containers_removable "$@"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -1608,7 +1619,7 @@ _docker_container_run_and_create() {
|
||||||
--tty -t
|
--tty -t
|
||||||
"
|
"
|
||||||
|
|
||||||
if [ "$command" = "run" -o "$subcommand" = "run" ] ; then
|
if [ "$command" = "run" ] || [ "$subcommand" = "run" ] ; then
|
||||||
options_with_args="$options_with_args
|
options_with_args="$options_with_args
|
||||||
--detach-keys
|
--detach-keys
|
||||||
"
|
"
|
||||||
|
@ -1686,7 +1697,7 @@ _docker_container_run_and_create() {
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--env|-e)
|
--env|-e)
|
||||||
# we do not append a "=" here because "-e VARNAME" is legal systax, too
|
# we do not append a "=" here because "-e VARNAME" is legal syntax, too
|
||||||
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
||||||
__docker_nospace
|
__docker_nospace
|
||||||
return
|
return
|
||||||
|
@ -1699,6 +1710,7 @@ _docker_container_run_and_create() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) )
|
COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) )
|
||||||
|
# shellcheck disable=SC2128
|
||||||
if [ "$COMPREPLY" = "container:" ]; then
|
if [ "$COMPREPLY" = "container:" ]; then
|
||||||
__docker_nospace
|
__docker_nospace
|
||||||
fi
|
fi
|
||||||
|
@ -1753,6 +1765,7 @@ _docker_container_run_and_create() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) )
|
COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) )
|
||||||
|
# shellcheck disable=SC2128
|
||||||
if [ "$COMPREPLY" = "container:" ]; then
|
if [ "$COMPREPLY" = "container:" ]; then
|
||||||
__docker_nospace
|
__docker_nospace
|
||||||
fi
|
fi
|
||||||
|
@ -1806,8 +1819,8 @@ _docker_container_run_and_create() {
|
||||||
COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
|
local counter=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" )
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_images
|
__docker_complete_images
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1816,7 +1829,7 @@ _docker_container_run_and_create() {
|
||||||
|
|
||||||
_docker_container_start() {
|
_docker_container_start() {
|
||||||
__docker_complete_detach_keys && return
|
__docker_complete_detach_keys && return
|
||||||
|
# shellcheck disable=SC2078
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
--checkpoint)
|
--checkpoint)
|
||||||
if [ __docker_daemon_is_experimental ] ; then
|
if [ __docker_daemon_is_experimental ] ; then
|
||||||
|
@ -1838,7 +1851,7 @@ _docker_container_start() {
|
||||||
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_complete_containers_stopped
|
__docker_complete_containers_stopped "$@"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -1884,7 +1897,7 @@ _docker_container_top() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_running
|
__docker_complete_containers_running
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -1898,8 +1911,8 @@ _docker_container_unpause() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_containers_unpauseable
|
__docker_complete_containers_unpauseable "$@"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -2098,7 +2111,7 @@ _docker_daemon() {
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--storage-driver|-s)
|
--storage-driver|-s)
|
||||||
COMPREPLY=( $( compgen -W "aufs btrfs devicemapper overlay overlay2 vfs zfs" -- "$(echo $cur | tr '[:upper:]' '[:lower:]')" ) )
|
COMPREPLY=( $( compgen -W "aufs btrfs devicemapper overlay overlay2 vfs zfs" -- "$(echo "$cur" | tr '[:upper:]' '[:lower:]')" ) )
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--storage-opt)
|
--storage-opt)
|
||||||
|
@ -2211,7 +2224,7 @@ _docker_export() {
|
||||||
|
|
||||||
_docker_help() {
|
_docker_help() {
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -2348,8 +2361,8 @@ _docker_image_build() {
|
||||||
COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
|
local counter=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" )
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
_filedir -d
|
_filedir -d
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -2369,7 +2382,7 @@ _docker_image_history() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_images
|
__docker_complete_images
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -2393,12 +2406,12 @@ _docker_image_import() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--change|-c|--message|-m')
|
local counter=$(__docker_pos_first_nonflag '--change|-c|--message|-m')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
(( counter++ ))
|
(( counter++ ))
|
||||||
|
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_image_repos_and_tags
|
__docker_complete_image_repos_and_tags
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -2493,7 +2506,7 @@ _docker_image_pull() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
for arg in "${COMP_WORDS[@]}"; do
|
for arg in "${COMP_WORDS[@]}"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--all-tags|-a)
|
--all-tags|-a)
|
||||||
|
@ -2515,7 +2528,7 @@ _docker_image_push() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_image_repos_and_tags
|
__docker_complete_image_repos_and_tags
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -2567,13 +2580,13 @@ _docker_image_tag() {
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
|
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_image_repos_and_tags
|
__docker_complete_image_repos_and_tags
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
(( counter++ ))
|
(( counter++ ))
|
||||||
|
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_image_repos_and_tags
|
__docker_complete_image_repos_and_tags
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -2737,10 +2750,10 @@ _docker_network_connect() {
|
||||||
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
|
local counter=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" )
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_networks
|
__docker_complete_networks
|
||||||
elif [ $cword -eq $(($counter + 1)) ]; then
|
elif [ "$cword" -eq $((counter + 1)) ]; then
|
||||||
__docker_complete_containers_all
|
__docker_complete_containers_all
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -2788,9 +2801,9 @@ _docker_network_disconnect() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_networks
|
__docker_complete_networks
|
||||||
elif [ $cword -eq $(($counter + 1)) ]; then
|
elif [ "$cword" -eq $((counter + 1)) ]; then
|
||||||
__docker_complete_containers_in_network "$prev"
|
__docker_complete_containers_in_network "$prev"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -2969,8 +2982,8 @@ _docker_service_logs() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--since|--tail')
|
local counter=$(__docker_pos_first_nonflag '--since|--tail')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_services_and_tasks
|
__docker_complete_services_and_tasks "$@"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -3076,7 +3089,7 @@ _docker_service_ps() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--filter|-f')
|
local counter=$(__docker_pos_first_nonflag '--filter|-f')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_services
|
__docker_complete_services
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -3321,13 +3334,13 @@ _docker_service_update_and_create() {
|
||||||
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
|
local counter=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" )
|
||||||
if [ "$subcommand" = "update" ] ; then
|
if [ "$subcommand" = "update" ] ; then
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_services
|
__docker_complete_services
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_images
|
__docker_complete_images
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -3466,7 +3479,7 @@ _docker_swarm_join_token() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$( __docker_pos_first_nonflag )
|
local counter=$( __docker_pos_first_nonflag )
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) )
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -3685,7 +3698,7 @@ _docker_node_update() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--availability|--label-add|--label-rm|--role')
|
local counter=$(__docker_pos_first_nonflag '--availability|--label-add|--label-rm|--role')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_nodes
|
__docker_complete_nodes
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -3732,10 +3745,10 @@ _docker_plugin_create() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
# reponame
|
# reponame
|
||||||
return
|
return
|
||||||
elif [ $cword -eq $((counter + 1)) ]; then
|
elif [ "$cword" -eq $((counter + 1)) ]; then
|
||||||
_filedir -d
|
_filedir -d
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -3749,7 +3762,7 @@ _docker_plugin_disable() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_plugins_installed --filter enabled=true
|
__docker_complete_plugins_installed --filter enabled=true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -3769,7 +3782,7 @@ _docker_plugin_enable() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--timeout')
|
local counter=$(__docker_pos_first_nonflag '--timeout')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_plugins_installed --filter enabled=false
|
__docker_complete_plugins_installed --filter enabled=false
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -3849,7 +3862,7 @@ _docker_plugin_push() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_plugins_installed
|
__docker_complete_plugins_installed
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -3878,7 +3891,7 @@ _docker_plugin_set() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_plugins_installed
|
__docker_complete_plugins_installed
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -3892,10 +3905,10 @@ _docker_plugin_upgrade() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag)
|
local counter=$(__docker_pos_first_nonflag)
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_plugins_installed
|
__docker_complete_plugins_installed
|
||||||
__ltrim_colon_completions "$cur"
|
__ltrim_colon_completions "$cur"
|
||||||
elif [ $cword -eq $((counter + 1)) ]; then
|
elif [ "$cword" -eq $((counter + 1)) ]; then
|
||||||
local plugin_images="$(__docker_plugins_installed)"
|
local plugin_images="$(__docker_plugins_installed)"
|
||||||
COMPREPLY=( $(compgen -S : -W "${plugin_images%:*}" -- "$cur") )
|
COMPREPLY=( $(compgen -S : -W "${plugin_images%:*}" -- "$cur") )
|
||||||
__docker_nospace
|
__docker_nospace
|
||||||
|
@ -3930,7 +3943,7 @@ _docker_restart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_rm() {
|
_docker_rm() {
|
||||||
_docker_container_rm
|
_docker_container_rm "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_rmi() {
|
_docker_rmi() {
|
||||||
|
@ -4189,7 +4202,7 @@ _docker_stack_ps() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--filter|-f')
|
local counter=$(__docker_pos_first_nonflag '--filter|-f')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_stacks
|
__docker_complete_stacks
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -4243,7 +4256,7 @@ _docker_stack_services() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local counter=$(__docker_pos_first_nonflag '--filter|-f|--format')
|
local counter=$(__docker_pos_first_nonflag '--filter|-f|--format')
|
||||||
if [ $cword -eq $counter ]; then
|
if [ "$cword" -eq "$counter" ]; then
|
||||||
__docker_complete_stacks
|
__docker_complete_stacks
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -4256,7 +4269,7 @@ _docker_stack_up() {
|
||||||
|
|
||||||
|
|
||||||
_docker_start() {
|
_docker_start() {
|
||||||
_docker_container_start
|
_docker_container_start "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_stats() {
|
_docker_stats() {
|
||||||
|
@ -4431,7 +4444,7 @@ _docker_tag() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_unpause() {
|
_docker_unpause() {
|
||||||
_docker_container_unpause
|
_docker_container_unpause "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_update() {
|
_docker_update() {
|
||||||
|
@ -4685,7 +4698,7 @@ _docker() {
|
||||||
|
|
||||||
local command='docker' command_pos=0 subcommand_pos
|
local command='docker' command_pos=0 subcommand_pos
|
||||||
local counter=1
|
local counter=1
|
||||||
while [ $counter -lt $cword ]; do
|
while [ "$counter" -lt "$cword" ]; do
|
||||||
case "${words[$counter]}" in
|
case "${words[$counter]}" in
|
||||||
# save host so that completion can use custom daemon
|
# save host so that completion can use custom daemon
|
||||||
--host|-H)
|
--host|-H)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
DEV_DOCKER_IMAGE_NAME = docker-cli-dev
|
DEV_DOCKER_IMAGE_NAME = docker-cli-dev
|
||||||
LINTER_IMAGE_NAME = docker-cli-lint
|
LINTER_IMAGE_NAME = docker-cli-lint
|
||||||
CROSS_IMAGE_NAME = docker-cli-cross
|
CROSS_IMAGE_NAME = docker-cli-cross
|
||||||
|
VALIDATE_IMAGE_NAME = docker-cli-validate
|
||||||
MOUNTS = -v "$(CURDIR)":/go/src/github.com/docker/cli
|
MOUNTS = -v "$(CURDIR)":/go/src/github.com/docker/cli
|
||||||
VERSION = $(shell cat VERSION)
|
VERSION = $(shell cat VERSION)
|
||||||
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT
|
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT
|
||||||
|
@ -25,6 +26,9 @@ build_linter_image:
|
||||||
build_cross_image:
|
build_cross_image:
|
||||||
docker build -t $(CROSS_IMAGE_NAME) -f ./dockerfiles/Dockerfile.cross .
|
docker build -t $(CROSS_IMAGE_NAME) -f ./dockerfiles/Dockerfile.cross .
|
||||||
|
|
||||||
|
.PHONY: build_validate_image
|
||||||
|
build_validate_image:
|
||||||
|
docker build -t $(VALIDATE_IMAGE_NAME) -f ./dockerfiles/Dockerfile.validate .
|
||||||
|
|
||||||
# build executable using a container
|
# build executable using a container
|
||||||
binary: build_docker_image
|
binary: build_docker_image
|
||||||
|
@ -80,3 +84,7 @@ manpages: build_docker_image
|
||||||
.PHONY: yamldocs
|
.PHONY: yamldocs
|
||||||
yamldocs: build_docker_image
|
yamldocs: build_docker_image
|
||||||
docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make yamldocs
|
docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make yamldocs
|
||||||
|
|
||||||
|
.PHONY: shellcheck
|
||||||
|
shellcheck: build_validate_image
|
||||||
|
docker run -ti --rm -v "$(CURDIR)":/tmp $(VALIDATE_IMAGE_NAME) make shellcheck
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
FROM debian:stretch-slim
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get -y install make shellcheck && \
|
||||||
|
apt-get clean
|
||||||
|
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
|
CMD bash
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Maintain an array of files to shellcheck not the best solution but will do for the time being
|
||||||
|
FILES=()
|
||||||
|
FILES+=("contrib/completion/bash/docker")
|
||||||
|
FILES+=("scripts/validate/shellcheck")
|
||||||
|
|
||||||
|
for f in "${FILES[@]}"; do
|
||||||
|
shellcheck "$f"
|
||||||
|
done
|
Loading…
Reference in New Issue