Signed-off-by: Steve Durrheimer <s.durrheimer@gmail.com>
| ... | ... |
@@ -138,7 +138,7 @@ __docker_containers_names() {
|
| 138 | 138 |
__docker_get_containers all names "$@" |
| 139 | 139 |
} |
| 140 | 140 |
|
| 141 |
-__docker_plugins() {
|
|
| 141 |
+__docker_complete_info_plugins() {
|
|
| 142 | 142 |
[[ $PREFIX = -* ]] && return 1 |
| 143 | 143 |
integer ret=1 |
| 144 | 144 |
emulate -L zsh |
| ... | ... |
@@ -451,7 +451,7 @@ __docker_network_complete_ls_filters() {
|
| 451 | 451 |
if compset -P '*='; then |
| 452 | 452 |
case "${${words[-1]%=*}#*=}" in
|
| 453 | 453 |
(driver) |
| 454 |
- __docker_plugins Network && ret=0 |
|
| 454 |
+ __docker_complete_info_plugins Network && ret=0 |
|
| 455 | 455 |
;; |
| 456 | 456 |
(id) |
| 457 | 457 |
__docker_networks_ids && ret=0 |
| ... | ... |
@@ -697,7 +697,6 @@ __docker_nodes() {
|
| 697 | 697 |
[[ $filter != "none") ]] && args=("-f $filter")
|
| 698 | 698 |
|
| 699 | 699 |
lines=(${(f)"$(_call_program commands docker $docker_options node ls $args)"})
|
| 700 |
- |
|
| 701 | 700 |
# Parse header line to find columns |
| 702 | 701 |
local i=1 j=1 k header=${lines[1]}
|
| 703 | 702 |
declare -A begin end |
| ... | ... |
@@ -848,6 +847,84 @@ __docker_node_subcommand() {
|
| 848 | 848 |
|
| 849 | 849 |
# EO node |
| 850 | 850 |
|
| 851 |
+# BO plugin |
|
| 852 |
+ |
|
| 853 |
+__docker_complete_plugins() {
|
|
| 854 |
+ [[ $PREFIX = -* ]] && return 1 |
|
| 855 |
+ integer ret=1 |
|
| 856 |
+ local line s |
|
| 857 |
+ declare -a lines plugins |
|
| 858 |
+ |
|
| 859 |
+ lines=(${(f)"$(_call_program commands docker $docker_options plugin ls)"})
|
|
| 860 |
+ |
|
| 861 |
+ # Parse header line to find columns |
|
| 862 |
+ local i=1 j=1 k header=${lines[1]}
|
|
| 863 |
+ declare -A begin end |
|
| 864 |
+ while (( j < ${#header} - 1 )); do
|
|
| 865 |
+ i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
|
|
| 866 |
+ j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
|
|
| 867 |
+ k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
|
|
| 868 |
+ begin[${header[$i,$((j-1))]}]=$i
|
|
| 869 |
+ end[${header[$i,$((j-1))]}]=$k
|
|
| 870 |
+ done |
|
| 871 |
+ end[${header[$i,$((j-1))]}]=-1
|
|
| 872 |
+ lines=(${lines[2,-1]})
|
|
| 873 |
+ |
|
| 874 |
+ # Name |
|
| 875 |
+ for line in $lines; do |
|
| 876 |
+ s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
|
|
| 877 |
+ s="$s:${(l:7:: :::)${${line[${begin[TAG]},${end[TAG]}]}%% ##}}"
|
|
| 878 |
+ plugins=($plugins $s) |
|
| 879 |
+ done |
|
| 880 |
+ |
|
| 881 |
+ _describe -t plugins-list "plugins" plugins "$@" && ret=0 |
|
| 882 |
+ return ret |
|
| 883 |
+} |
|
| 884 |
+ |
|
| 885 |
+__docker_plugin_commands() {
|
|
| 886 |
+ local -a _docker_plugin_subcommands |
|
| 887 |
+ _docker_plugin_subcommands=( |
|
| 888 |
+ "disable:Disable a plugin" |
|
| 889 |
+ "enable:Enable a plugin" |
|
| 890 |
+ "inspect:Return low-level information about a plugin" |
|
| 891 |
+ "install:Install a plugin" |
|
| 892 |
+ "ls:List plugins" |
|
| 893 |
+ "push:Push a plugin" |
|
| 894 |
+ "rm:Remove a plugin" |
|
| 895 |
+ "set:Change settings for a plugin" |
|
| 896 |
+ ) |
|
| 897 |
+ _describe -t docker-plugin-commands "docker plugin command" _docker_plugin_subcommands |
|
| 898 |
+} |
|
| 899 |
+ |
|
| 900 |
+__docker_plugin_subcommand() {
|
|
| 901 |
+ local -a _command_args opts_help |
|
| 902 |
+ local expl help="--help" |
|
| 903 |
+ integer ret=1 |
|
| 904 |
+ |
|
| 905 |
+ opts_help=("(: -)--help[Print usage]")
|
|
| 906 |
+ |
|
| 907 |
+ case "$words[1]" in |
|
| 908 |
+ (disable|enable|inspect|install|ls|push|rm) |
|
| 909 |
+ _arguments $(__docker_arguments) \ |
|
| 910 |
+ $opts_help \ |
|
| 911 |
+ "($help -)1:plugin:__docker_complete_plugins" && ret=0 |
|
| 912 |
+ ;; |
|
| 913 |
+ (set) |
|
| 914 |
+ _arguments $(__docker_arguments) \ |
|
| 915 |
+ $opts_help \ |
|
| 916 |
+ "($help -)1:plugin:__docker_complete_plugins" \ |
|
| 917 |
+ "($help-)*:key=value: " && ret=0 |
|
| 918 |
+ ;; |
|
| 919 |
+ (help) |
|
| 920 |
+ _arguments $(__docker_arguments) ":subcommand:__docker_plugin_commands" && ret=0 |
|
| 921 |
+ ;; |
|
| 922 |
+ esac |
|
| 923 |
+ |
|
| 924 |
+ return ret |
|
| 925 |
+} |
|
| 926 |
+ |
|
| 927 |
+# EO plugin |
|
| 928 |
+ |
|
| 851 | 929 |
# BO swarm |
| 852 | 930 |
|
| 853 | 931 |
__docker_swarm_commands() {
|
| ... | ... |
@@ -927,7 +1004,7 @@ __docker_volume_complete_ls_filters() {
|
| 927 | 927 |
_describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0 |
| 928 | 928 |
;; |
| 929 | 929 |
(driver) |
| 930 |
- __docker_plugins Volume && ret=0 |
|
| 930 |
+ __docker_complete_info_plugins Volume && ret=0 |
|
| 931 | 931 |
;; |
| 932 | 932 |
(name) |
| 933 | 933 |
__docker_volumes && ret=0 |
| ... | ... |
@@ -1470,6 +1547,23 @@ __docker_subcommand() {
|
| 1470 | 1470 |
$opts_help \ |
| 1471 | 1471 |
"($help -)*:containers:__docker_runningcontainers" && ret=0 |
| 1472 | 1472 |
;; |
| 1473 |
+ (plugin) |
|
| 1474 |
+ local curcontext="$curcontext" state |
|
| 1475 |
+ _arguments $(__docker_arguments) \ |
|
| 1476 |
+ $opts_help \ |
|
| 1477 |
+ "($help -): :->command" \ |
|
| 1478 |
+ "($help -)*:: :->option-or-argument" && ret=0 |
|
| 1479 |
+ |
|
| 1480 |
+ case $state in |
|
| 1481 |
+ (command) |
|
| 1482 |
+ __docker_plugin_commands && ret=0 |
|
| 1483 |
+ ;; |
|
| 1484 |
+ (option-or-argument) |
|
| 1485 |
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
|
|
| 1486 |
+ __docker_plugin_subcommand && ret=0 |
|
| 1487 |
+ ;; |
|
| 1488 |
+ esac |
|
| 1489 |
+ ;; |
|
| 1473 | 1490 |
(port) |
| 1474 | 1491 |
_arguments $(__docker_arguments) \ |
| 1475 | 1492 |
$opts_help \ |