Check key specific bash subcompletions first

This is a refactoring in preparation of cleaning up the handling
of key specific subcompletions.

The new `__docker_map_key_of_current_option()` function will be used
instead of the `__docker_map_key_of_current_option()` idiom in the
following commit.
As this function is very specific, checks using it should be executed
before those checking for `$prev`.

This commit just moves the checks without any modification.

Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
Harald Albers 2016-02-07 10:02:30 -08:00 committed by Tibor Vass
parent a9dd907004
commit 904481becd
1 changed files with 64 additions and 64 deletions

View File

@ -787,6 +787,29 @@ _docker_daemon() {
--userns-remap
"
__docker_complete_log_driver_options && return
case "${words[$cword-2]}$prev=" in
# completions for --storage-opt
*dm.@(blkdiscard|override_udev_sync_check|use_deferred_@(removal|deletion))=*)
COMPREPLY=( $( compgen -W "false true" -- "${cur#=}" ) )
return
;;
*dm.fs=*)
COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur#=}" ) )
return
;;
*dm.thinpooldev=*)
_filedir
return
;;
# completions for --cluster-store-opt
*kv.*file=*)
_filedir
return
;;
esac
case "$prev" in
--authorization-plugin)
__docker_complete_plugins Authorization
@ -869,29 +892,6 @@ _docker_daemon() {
;;
esac
__docker_complete_log_driver_options && return
case "${words[$cword-2]}$prev=" in
# completions for --storage-opt
*dm.@(blkdiscard|override_udev_sync_check|use_deferred_@(removal|deletion))=*)
COMPREPLY=( $( compgen -W "false true" -- "${cur#=}" ) )
return
;;
*dm.fs=*)
COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur#=}" ) )
return
;;
*dm.thinpooldev=*)
_filedir
return
;;
# completions for --cluster-store-opt
*kv.*file=*)
_filedir
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
@ -1051,6 +1051,16 @@ _docker_history() {
}
_docker_images() {
case "${words[$cword-2]}$prev=" in
*dangling=*)
COMPREPLY=( $( compgen -W "true false" -- "${cur#=}" ) )
return
;;
*label=*)
return
;;
esac
case "$prev" in
--filter|-f)
COMPREPLY=( $( compgen -S = -W "dangling label" -- "$cur" ) )
@ -1062,16 +1072,6 @@ _docker_images() {
;;
esac
case "${words[$cword-2]}$prev=" in
*dangling=*)
COMPREPLY=( $( compgen -W "true false" -- "${cur#=}" ) )
return
;;
*label=*)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--all -a --digests --filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) )
@ -1329,14 +1329,6 @@ _docker_network_inspect() {
}
_docker_network_ls() {
case "$prev" in
--filter|-f)
COMPREPLY=( $( compgen -S = -W "id name type" -- "$cur" ) )
__docker_nospace
return
;;
esac
case "${words[$cword-2]}$prev=" in
*id=*)
cur="${cur#=}"
@ -1354,6 +1346,14 @@ _docker_network_ls() {
;;
esac
case "$prev" in
--filter|-f)
COMPREPLY=( $( compgen -S = -W "id name type" -- "$cur" ) )
__docker_nospace
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--filter -f --help --no-trunc --quiet -q" -- "$cur" ) )
@ -1421,20 +1421,6 @@ _docker_port() {
}
_docker_ps() {
case "$prev" in
--before|--since)
__docker_complete_containers_all
;;
--filter|-f)
COMPREPLY=( $( compgen -S = -W "ancestor exited id label name status" -- "$cur" ) )
__docker_nospace
return
;;
--format|-n)
return
;;
esac
case "${words[$cword-2]}$prev=" in
*ancestor=*)
cur="${cur#=}"
@ -1457,6 +1443,20 @@ _docker_ps() {
;;
esac
case "$prev" in
--before|--since)
__docker_complete_containers_all
;;
--filter|-f)
COMPREPLY=( $( compgen -S = -W "ancestor exited id label name status" -- "$cur" ) )
__docker_nospace
return
;;
--format|-n)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--all -a --before --filter -f --format --help --latest -l -n --no-trunc --quiet -q --size -s --since" -- "$cur" ) )
@ -1651,6 +1651,8 @@ _docker_run() {
local all_options="$options_with_args $boolean_options"
__docker_complete_log_driver_options && return
case "$prev" in
--add-host)
case "$cur" in
@ -1797,8 +1799,6 @@ _docker_run() {
;;
esac
__docker_complete_log_driver_options && return
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
@ -2015,17 +2015,17 @@ _docker_volume_inspect() {
}
_docker_volume_ls() {
case "$prev" in
--filter|-f)
COMPREPLY=( $( compgen -S = -W "dangling" -- "$cur" ) )
__docker_nospace
case "${words[$cword-2]}$prev=" in
*dangling=*)
COMPREPLY=( $( compgen -W "true false" -- "${cur#=}" ) )
return
;;
esac
case "${words[$cword-2]}$prev=" in
*dangling=*)
COMPREPLY=( $( compgen -W "true false" -- "${cur#=}" ) )
case "$prev" in
--filter|-f)
COMPREPLY=( $( compgen -S = -W "dangling" -- "$cur" ) )
__docker_nospace
return
;;
esac