Procházet zdrojové kódy

Merge pull request #28198 from sdurrheimer/zsh-completion-system-subcommand

Add zsh completion for new 'docker system' subcommands
Vincent Demeester před 8 roky
rodič
revize
b7ecc2e3c0
1 změnil soubory, kde provedl 74 přidání a 12 odebrání
  1. 74 12
      contrib/completion/zsh/_docker

+ 74 - 12
contrib/completion/zsh/_docker

@@ -1825,6 +1825,56 @@ __docker_swarm_subcommand() {
 
 
 # EO swarm
 # EO swarm
 
 
+# BO system
+
+__docker_system_commands() {
+    local -a _docker_system_subcommands
+    _docker_system_subcommands=(
+        "df:Show docker disk usage"
+        "events:Get real time events from the server"
+        "info:Display system-wide information"
+        "prune:Remove unused data"
+    )
+    _describe -t docker-system-commands "docker system command" _docker_system_subcommands
+}
+
+__docker_system_subcommand() {
+    local -a _command_args opts_help
+    local expl help="--help"
+    integer ret=1
+
+    opts_help=("(: -)--help[Print usage]")
+
+    case "$words[1]" in
+        (df)
+            # @TODO
+            ;;
+        (events)
+            _arguments $(__docker_arguments) \
+                $opts_help \
+                "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \
+                "($help)--since=[Events created since this timestamp]:timestamp: " \
+                "($help)--until=[Events created until this timestamp]:timestamp: " \
+                "($help)--format=[Format the output using the given go template]:template: " && ret=0
+            ;;
+        (info)
+            _arguments $(__docker_arguments) \
+                $opts_help \
+                "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0
+            ;;
+        (prune)
+            # @TODO
+            ;;
+        (help)
+            _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0
+            ;;
+    esac
+
+    return ret
+}
+
+# EO system
+
 # BO volume
 # BO volume
 
 
 __docker_volume_complete_ls_filters() {
 __docker_volume_complete_ls_filters() {
@@ -2093,13 +2143,8 @@ __docker_subcommand() {
                     ;;
                     ;;
             esac
             esac
             ;;
             ;;
-        (events)
-            _arguments $(__docker_arguments) \
-                $opts_help \
-                "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \
-                "($help)--since=[Events created since this timestamp]:timestamp: " \
-                "($help)--until=[Events created until this timestamp]:timestamp: " \
-                "($help)--format=[Format the output using the given go template]:template: " && ret=0
+        (events|info)
+            __docker_system_subcommand && ret=0
             ;;
             ;;
         (image)
         (image)
             local curcontext="$curcontext" state
             local curcontext="$curcontext" state
@@ -2122,11 +2167,6 @@ __docker_subcommand() {
             words[1]='ls'
             words[1]='ls'
             __docker_image_subcommand && ret=0
             __docker_image_subcommand && ret=0
             ;;
             ;;
-        (info|version)
-            _arguments $(__docker_arguments) \
-                $opts_help \
-                "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0
-            ;;
         (inspect)
         (inspect)
             local state
             local state
             _arguments $(__docker_arguments) \
             _arguments $(__docker_arguments) \
@@ -2267,6 +2307,28 @@ __docker_subcommand() {
                     ;;
                     ;;
             esac
             esac
             ;;
             ;;
+        (system)
+            local curcontext="$curcontext" state
+            _arguments $(__docker_arguments) \
+                $opts_help \
+                "($help -): :->command" \
+                "($help -)*:: :->option-or-argument" && ret=0
+
+            case $state in
+                (command)
+                    __docker_system_commands && ret=0
+                    ;;
+                (option-or-argument)
+                    curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+                    __docker_system_subcommand && ret=0
+                    ;;
+            esac
+            ;;
+        (version)
+            _arguments $(__docker_arguments) \
+                $opts_help \
+                "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0
+            ;;
         (volume)
         (volume)
             local curcontext="$curcontext" state
             local curcontext="$curcontext" state
             _arguments $(__docker_arguments) \
             _arguments $(__docker_arguments) \