Browse code

Merge pull request #31150 from thaJeztah/1.13.2-completion-scripts

17.03 bash/zsh completion script cherry-picks

Victor Vieux authored on 2017/02/19 17:46:42
Showing 2 changed files
... ...
@@ -3367,6 +3367,7 @@ _docker_plugin() {
3367 3367
 		push
3368 3368
 		rm
3369 3369
 		set
3370
+		upgrade
3370 3371
 	"
3371 3372
 	local aliases="
3372 3373
 		list
... ...
@@ -3521,6 +3522,25 @@ _docker_plugin_set() {
3521 3521
 	esac
3522 3522
 }
3523 3523
 
3524
+_docker_plugin_upgrade() {
3525
+	case "$cur" in
3526
+		-*)
3527
+			COMPREPLY=( $( compgen -W "--disable-content-trust --grant-all-permissions --help --skip-remote-check" -- "$cur" ) )
3528
+			;;
3529
+		*)
3530
+			local counter=$(__docker_pos_first_nonflag)
3531
+			if [ $cword -eq $counter ]; then
3532
+				__docker_complete_plugins_installed
3533
+				__ltrim_colon_completions "$cur"
3534
+			elif [ $cword -eq  $((counter + 1)) ]; then
3535
+				local plugin_images="$(__docker_plugins_installed)"
3536
+				COMPREPLY=( $(compgen -S : -W "${plugin_images%:*}" -- "$cur") )
3537
+				__docker_nospace
3538
+			fi
3539
+			;;
3540
+	esac
3541
+}
3542
+
3524 3543
 
3525 3544
 _docker_port() {
3526 3545
 	_docker_container_port
... ...
@@ -494,6 +494,57 @@ __docker_complete_prune_filters() {
494 494
     return ret
495 495
 }
496 496
 
497
+# BO checkpoint
498
+
499
+__docker_checkpoint_commands() {
500
+    local -a _docker_checkpoint_subcommands
501
+    _docker_checkpoint_subcommands=(
502
+        "create:Create a checkpoint from a running container"
503
+        "ls:List checkpoints for a container"
504
+        "rm:Remove a checkpoint"
505
+    )
506
+    _describe -t docker-checkpoint-commands "docker checkpoint command" _docker_checkpoint_subcommands
507
+}
508
+
509
+__docker_checkpoint_subcommand() {
510
+    local -a _command_args opts_help
511
+    local expl help="--help"
512
+    integer ret=1
513
+
514
+    opts_help=("(: -)--help[Print usage]")
515
+
516
+    case "$words[1]" in
517
+        (create)
518
+            _arguments $(__docker_arguments) \
519
+                $opts_help \
520
+                "($help)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \
521
+                "($help)--leave-running[Leave the container running after checkpoint]" \
522
+                "($help -)1:container:__docker_complete_running_containers" \
523
+                "($help -)2:checkpoint: " && ret=0
524
+            ;;
525
+        (ls|list)
526
+            _arguments $(__docker_arguments) \
527
+                $opts_help \
528
+                "($help)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \
529
+                "($help -)1:container:__docker_complete_containers" && ret=0
530
+            ;;
531
+        (rm|remove)
532
+            _arguments $(__docker_arguments) \
533
+                $opts_help \
534
+                "($help)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \
535
+                "($help -)1:container:__docker_complete_containers" \
536
+                "($help -)2:checkpoint: " && ret=0
537
+            ;;
538
+        (help)
539
+            _arguments $(__docker_arguments) ":subcommand:__docker_checkpoint_commands" && ret=0
540
+            ;;
541
+    esac
542
+
543
+    return ret
544
+}
545
+
546
+# EO checkpoint
547
+
497 548
 # BO container
498 549
 
499 550
 __docker_container_commands() {
... ...
@@ -945,6 +996,7 @@ __docker_image_subcommand() {
945 945
                 "($help -q --quiet)"{-q,--quiet}"[Suppress verbose build output]" \
946 946
                 "($help)--rm[Remove intermediate containers after a successful build]" \
947 947
                 "($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: " \
948
+                "($help)--squash[Squash newly built layers into a single new layer]" \
948 949
                 "($help -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_complete_repositories_with_tags" \
949 950
                 "($help)*--ulimit=[ulimit options]:ulimit: " \
950 951
                 "($help)--userns=[Container user namespace]:user namespace:(host)" \
... ...
@@ -1509,6 +1561,7 @@ __docker_plugin_commands() {
1509 1509
         "push:Push a plugin"
1510 1510
         "rm:Remove a plugin"
1511 1511
         "set:Change settings for a plugin"
1512
+        "upgrade:Upgrade an existing plugin"
1512 1513
     )
1513 1514
     _describe -t docker-plugin-commands "docker plugin command" _docker_plugin_subcommands
1514 1515
 }
... ...
@@ -1521,22 +1574,65 @@ __docker_plugin_subcommand() {
1521 1521
     opts_help=("(: -)--help[Print usage]")
1522 1522
 
1523 1523
     case "$words[1]" in
1524
-        (disable|enable|inspect|ls|push|rm)
1524
+        (disable)
1525
+            _arguments $(__docker_arguments) \
1526
+                $opts_help \
1527
+                "($help -f --force)"{-f,--force}"[Force the disable of an active plugin]" \
1528
+                "($help -)1:plugin:__docker_complete_plugins" && ret=0
1529
+            ;;
1530
+        (enable)
1525 1531
             _arguments $(__docker_arguments) \
1526 1532
                 $opts_help \
1533
+                "($help)--timeout=[HTTP client timeout (in seconds)]:timeout: " \
1527 1534
                 "($help -)1:plugin:__docker_complete_plugins" && ret=0
1528 1535
             ;;
1536
+        (inspect)
1537
+            _arguments $(__docker_arguments) \
1538
+                $opts_help \
1539
+                "($help -f --format)"{-f=,--format=}"[Format the output using the given Go template]:template: " \
1540
+                "($help -)*:plugin:__docker_complete_plugins" && ret=0
1541
+            ;;
1529 1542
         (install)
1530 1543
             _arguments $(__docker_arguments) \
1531 1544
                 $opts_help \
1532 1545
                 "($help)--alias=[Local name for plugin]:alias: " \
1546
+                "($help)--disable[Do not enable the plugin on install]" \
1547
+                "($help)--disable-content-trust[Skip image verification (default true)]" \
1548
+                "($help)--grant-all-permissions[Grant all permissions necessary to run the plugin]" \
1549
+                "($help -)1:plugin:__docker_complete_plugins" \
1550
+                "($help -)*:key=value: " && ret=0
1551
+            ;;
1552
+        (ls|list)
1553
+            _arguments $(__docker_arguments) \
1554
+                $opts_help \
1555
+                "($help)--no-trunc[Don't truncate output]" && ret=0
1556
+            ;;
1557
+        (push)
1558
+            _arguments $(__docker_arguments) \
1559
+                $opts_help \
1560
+                "($help)--disable-content-trust[Skip image verification (default true)]" \
1533 1561
                 "($help -)1:plugin:__docker_complete_plugins" && ret=0
1534 1562
             ;;
1563
+        (rm|remove)
1564
+            _arguments $(__docker_arguments) \
1565
+                $opts_help \
1566
+                "($help -f --force)"{-f,--force}"[Force the removal of an active plugin]" \
1567
+                "($help -)*:plugin:__docker_complete_plugins" && ret=0
1568
+            ;;
1535 1569
         (set)
1536 1570
             _arguments $(__docker_arguments) \
1537 1571
                 $opts_help \
1538 1572
                 "($help -)1:plugin:__docker_complete_plugins" \
1539
-                "($help-)*:key=value: " && ret=0
1573
+                "($help -)*:key=value: " && ret=0
1574
+            ;;
1575
+        (upgrade)
1576
+            _arguments $(__docker_arguments) \
1577
+                $opts_help \
1578
+                "($help)--disable-content-trust[Skip image verification (default true)]" \
1579
+                "($help)--grant-all-permissions[Grant all permissions necessary to run the plugin]" \
1580
+                "($help)--skip-remote-check[Do not check if specified remote plugin matches existing plugin image]" \
1581
+                "($help -)1:plugin:__docker_complete_plugins" \
1582
+                "($help -):remote: " && ret=0
1540 1583
             ;;
1541 1584
         (help)
1542 1585
             _arguments $(__docker_arguments) ":subcommand:__docker_plugin_commands" && ret=0
... ...
@@ -1762,6 +1858,7 @@ __docker_service_commands() {
1762 1762
     _docker_service_subcommands=(
1763 1763
         "create:Create a new service"
1764 1764
         "inspect:Display detailed information on one or more services"
1765
+        "logs:Fetch the logs of a service"
1765 1766
         "ls:List services"
1766 1767
         "rm:Remove one or more services"
1767 1768
         "scale:Scale one or multiple replicated services"
... ...
@@ -1839,6 +1936,17 @@ __docker_service_subcommand() {
1839 1839
                 "($help)--pretty[Print the information in a human friendly format]" \
1840 1840
                 "($help -)*:service:__docker_complete_services" && ret=0
1841 1841
             ;;
1842
+        (logs)
1843
+            _arguments $(__docker_arguments) \
1844
+                $opts_help \
1845
+                "($help)--details[Show extra details provided to logs]" \
1846
+                "($help -f --follow)"{-f,--follow}"[Follow log output]" \
1847
+                "($help)--no-resolve[Do not map IDs to Names]" \
1848
+                "($help)--since=[Show logs since timestamp]:timestamp: " \
1849
+                "($help)--tail=[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \
1850
+                "($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \
1851
+                "($help -)1:service:__docker_complete_services" && ret=0
1852
+            ;;
1842 1853
         (ls|list)
1843 1854
             _arguments $(__docker_arguments) \
1844 1855
                 $opts_help \
... ...
@@ -2065,6 +2173,8 @@ __docker_swarm_commands() {
2065 2065
         "join:Join a swarm as a node and/or manager"
2066 2066
         "join-token:Manage join tokens"
2067 2067
         "leave:Leave a swarm"
2068
+        "unlock:Unlock swarm"
2069
+        "unlock-key:Manage the unlock key"
2068 2070
         "update:Update the swarm"
2069 2071
     )
2070 2072
     _describe -t docker-swarm-commands "docker swarm command" _docker_swarm_subcommands
... ...
@@ -2081,7 +2191,11 @@ __docker_swarm_subcommand() {
2081 2081
         (init)
2082 2082
             _arguments $(__docker_arguments) \
2083 2083
                 $opts_help \
2084
-                "($help)--advertise-addr[Advertised address]:ip\:port: " \
2084
+                "($help)--advertise-addr=[Advertised address]:ip\:port: " \
2085
+                "($help)--autolock[Enable manager autolocking]" \
2086
+                "($help)--availability=[Availability of the node]:availability:(active drain pause)" \
2087
+                "($help)--cert-expiry=[Validity period for node certificates]:duration: " \
2088
+                "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \
2085 2089
                 "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \
2086 2090
                 "($help)--force-new-cluster[Force create a new cluster from current state]" \
2087 2091
                 "($help)--listen-addr=[Listen address]:ip\:port: " \
... ...
@@ -2110,12 +2224,23 @@ __docker_swarm_subcommand() {
2110 2110
                 $opts_help \
2111 2111
                 "($help -f --force)"{-f,--force}"[Force this node to leave the swarm, ignoring warnings]" && ret=0
2112 2112
             ;;
2113
+        (unlock)
2114
+            _arguments $(__docker_arguments) \
2115
+                $opts_help && ret=0
2116
+            ;;
2117
+        (unlock-key)
2118
+            _arguments $(__docker_arguments) \
2119
+                $opts_help \
2120
+                "($help -q --quiet)"{-q,--quiet}"[Only display token]" \
2121
+                "($help)--rotate[Rotate unlock token]" && ret=0
2122
+            ;;
2113 2123
         (update)
2114 2124
             _arguments $(__docker_arguments) \
2115 2125
                 $opts_help \
2126
+                "($help)--autolock[Enable manager autolocking]" \
2116 2127
                 "($help)--cert-expiry=[Validity period for node certificates]:duration: " \
2117
-                "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \
2118 2128
                 "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \
2129
+                "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \
2119 2130
                 "($help)--max-snapshots[Number of additional Raft snapshots to retain]" \
2120 2131
                 "($help)--snapshot-interval[Number of log entries between Raft snapshots]" \
2121 2132
                 "($help)--task-history-limit=[Task history retention limit]:limit: " && ret=0
... ...
@@ -2354,6 +2479,23 @@ __docker_subcommand() {
2354 2354
         (build|history|import|load|pull|push|save|tag)
2355 2355
             __docker_image_subcommand && ret=0
2356 2356
             ;;
2357
+        (checkpoint)
2358
+            local curcontext="$curcontext" state
2359
+            _arguments $(__docker_arguments) \
2360
+                $opts_help \
2361
+                "($help -): :->command" \
2362
+                "($help -)*:: :->option-or-argument" && ret=0
2363
+
2364
+            case $state in
2365
+                (command)
2366
+                    __docker_checkpoint_commands && ret=0
2367
+                    ;;
2368
+                (option-or-argument)
2369
+                    curcontext=${curcontext%:*:*}:docker-${words[-1]}:
2370
+                    __docker_checkpoint_subcommand && ret=0
2371
+                    ;;
2372
+            esac
2373
+            ;;
2357 2374
         (container)
2358 2375
             local curcontext="$curcontext" state
2359 2376
             _arguments $(__docker_arguments) \