소스 검색

Improve bash completion for `docker plugin enable|disable`

Signed-off-by: Harald Albers <github@albersweb.de>
Harald Albers 8 년 전
부모
커밋
f8456192ab
1개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 3
      contrib/completion/bash/docker

+ 6 - 3
contrib/completion/bash/docker

@@ -289,6 +289,8 @@ __docker_complete_plugins_bundled() {
 # the Docker plugin API.
 # the Docker plugin API.
 # By default, only names are returned.
 # By default, only names are returned.
 # Set DOCKER_COMPLETION_SHOW_PLUGIN_IDS=yes to also complete IDs.
 # Set DOCKER_COMPLETION_SHOW_PLUGIN_IDS=yes to also complete IDs.
+# Additional options to `docker plugin ls` may be specified in order to filter the list,
+# e.g. `__docker_plugins_installed --filter enabled=true`
 # For built-in pugins, see `__docker_plugins_bundled`.
 # For built-in pugins, see `__docker_plugins_bundled`.
 __docker_plugins_installed() {
 __docker_plugins_installed() {
 	local format
 	local format
@@ -297,12 +299,13 @@ __docker_plugins_installed() {
 	else
 	else
 		format='{{.Name}}'
 		format='{{.Name}}'
 	fi
 	fi
-	__docker_q plugin ls --format "$format"
+	__docker_q plugin ls --format "$format" "$@"
 }
 }
 
 
 # __docker_complete_plugins_installed applies completion of plugins that were installed
 # __docker_complete_plugins_installed applies completion of plugins that were installed
 # with the Docker plugin API, based on the current value of `$cur` or the value of
 # with the Docker plugin API, based on the current value of `$cur` or the value of
 # the optional first option `--cur`, if given.
 # the optional first option `--cur`, if given.
+# Additional filters may be appended, see `__docker_plugins_installed`.
 # For completion of built-in pugins, see `__docker_complete_plugins_bundled`.
 # For completion of built-in pugins, see `__docker_complete_plugins_bundled`.
 __docker_complete_plugins_installed() {
 __docker_complete_plugins_installed() {
 	local current="$cur"
 	local current="$cur"
@@ -3367,7 +3370,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
+				__docker_complete_plugins_installed --filter enabled=true
 			fi
 			fi
 			;;
 			;;
 	esac
 	esac
@@ -3387,7 +3390,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
+				__docker_complete_plugins_installed --filter enabled=false
 			fi
 			fi
 			;;
 			;;
 	esac
 	esac