Browse Source

Merge pull request #30642 from albers/completion-improve-plugin-enable

Improve bash completion for `docker plugin enable|disable`
Kenfe-Mickaël Laventure 8 years ago
parent
commit
1459dc573a
1 changed files with 6 additions and 3 deletions
  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"
@@ -3496,7 +3499,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
@@ -3516,7 +3519,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