Skip to content

Commit

Permalink
Check key specific bash subcompletions first
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
albers committed Feb 7, 2016
1 parent 78f2b8d commit 6f9bd6c
Showing 1 changed file with 63 additions and 63 deletions.
126 changes: 63 additions & 63 deletions contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" ) )
Expand Down Expand Up @@ -1051,23 +1051,23 @@ _docker_history() {
}

_docker_images() {
case "$prev" in
--filter|-f)
COMPREPLY=( $( compgen -S = -W "dangling label" -- "$cur" ) )
__docker_nospace
case "${words[$cword-2]}$prev=" in
*dangling=*)
COMPREPLY=( $( compgen -W "true false" -- "${cur#=}" ) )
return
;;
--format)
*label=*)
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 label" -- "$cur" ) )
__docker_nospace
return
;;
*label=*)
--format)
return
;;
esac
Expand Down Expand Up @@ -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#=}"
Expand All @@ -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" ) )
Expand Down Expand Up @@ -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#=}"
Expand All @@ -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" ) )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1797,8 +1799,6 @@ _docker_run() {
;;
esac

__docker_complete_log_driver_options && return

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f9bd6c

Please sign in to comment.