Browse code

Merge pull request #30396 from sdurrheimer/zsh-completion-hide-legacy-commands

Zsh completion hide legacy commands

Vincent Demeester authored on 2017/02/15 03:42:25
Showing 1 changed files
... ...
@@ -562,7 +562,7 @@ __docker_container_subcommand() {
562 562
         "($help)*--group=[Set one or more supplementary user groups for the container]:group:_groups"
563 563
         "($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts"
564 564
         "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]"
565
-        "($help)--init[Run an init inside the container that forwards signals and reaps processes]" \
565
+        "($help)--init[Run an init inside the container that forwards signals and reaps processes]"
566 566
         "($help)--ip=[IPv4 address]:IPv4: "
567 567
         "($help)--ip6=[IPv6 address]:IPv6: "
568 568
         "($help)--ipc=[IPC namespace to use]:IPC namespace: "
... ...
@@ -2344,14 +2344,28 @@ __docker_caching_policy() {
2344 2344
 
2345 2345
 __docker_commands() {
2346 2346
     local cache_policy
2347
+    integer force_invalidation=0
2347 2348
 
2348 2349
     zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
2349 2350
     if [[ -z "$cache_policy" ]]; then
2350 2351
         zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy
2351 2352
     fi
2352 2353
 
2353
-    if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \
2354
-        && ! _retrieve_cache docker_subcommands;
2354
+    if ( (( ! ${+_docker_hide_legacy_commands} )) || _cache_invalid docker_hide_legacy_commands ) \
2355
+       && ! _retrieve_cache docker_hide_legacy_commands;
2356
+    then
2357
+        _docker_hide_legacy_commands="${DOCKER_HIDE_LEGACY_COMMANDS}"
2358
+        _store_cache docker_hide_legacy_commands _docker_hide_legacy_commands
2359
+    fi
2360
+
2361
+    if [[ "${_docker_hide_legacy_commands}" != "${DOCKER_HIDE_LEGACY_COMMANDS}" ]]; then
2362
+        force_invalidation=1
2363
+        _docker_hide_legacy_commands="${DOCKER_HIDE_LEGACY_COMMANDS}"
2364
+        _store_cache docker_hide_legacy_commands _docker_hide_legacy_commands
2365
+    fi
2366
+
2367
+    if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands ) \
2368
+        && ! _retrieve_cache docker_subcommands || [[ ${force_invalidation} -eq 1 ]];
2355 2369
     then
2356 2370
         local -a lines
2357 2371
         lines=(${(f)"$(_call_program commands docker 2>&1)"})