Add windows specific bash completion for `docker run|create`

Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
Harald Albers 2017-01-25 10:24:27 +01:00 committed by Tibor Vass
parent 46c619655f
commit d9dbe8b6f6
1 changed files with 20 additions and 1 deletions

View File

@ -456,6 +456,18 @@ __docker_is_experimental() {
[ "$(__docker_q version -f '{{.Server.Experimental}}')" = "true" ]
}
# __docker_daemon_os_is tests whether the currently configured Docker daemon runs
# on the operating system passed in as the first argument.
# It does so by querying the daemon for its OS. The result is cached for the duration
# of one invocation of bash completion so that this function can be used to test for
# several different operating systems without additional costs.
# Known operating systems: linux, windows.
__docker_daemon_os_is() {
local expected_os="$1"
local actual_os=${daemon_os=$(__docker_q version -f '{{.Server.Os}}')}
[ "$actual_os" = "$expected_os" ]
}
# __docker_pos_first_nonflag finds the position of the first word that is neither
# option nor an option's argument. If there are options that require arguments,
# you should pass a glob describing those options, e.g. "--option1|-o|--option2"
@ -1401,6 +1413,13 @@ _docker_container_run() {
--volume -v
--workdir -w
"
__docker_daemon_os_is windows && options_with_args+="
--cpu-count
--cpu-percent
--credentialspec
--io-maxbandwidth
--io-maxiops
"
local boolean_options="
--disable-content-trust=false
@ -4146,7 +4165,7 @@ _docker() {
--tlskey
"
local host config
local host config daemon_os
COMPREPLY=()
local cur prev words cword