소스 검색

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

Zsh completion hide legacy commands
Vincent Demeester 8 년 전
부모
커밋
24523d9b75
1개의 변경된 파일17개의 추가작업 그리고 3개의 파일을 삭제
  1. 17 3
      contrib/completion/zsh/_docker

+ 17 - 3
contrib/completion/zsh/_docker

@@ -562,7 +562,7 @@ __docker_container_subcommand() {
         "($help)*--group=[Set one or more supplementary user groups for the container]:group:_groups"
         "($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts"
         "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]"
-        "($help)--init[Run an init inside the container that forwards signals and reaps processes]" \
+        "($help)--init[Run an init inside the container that forwards signals and reaps processes]"
         "($help)--ip=[IPv4 address]:IPv4: "
         "($help)--ip6=[IPv6 address]:IPv6: "
         "($help)--ipc=[IPC namespace to use]:IPC namespace: "
@@ -2344,14 +2344,28 @@ __docker_caching_policy() {
 
 __docker_commands() {
     local cache_policy
+    integer force_invalidation=0
 
     zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
     if [[ -z "$cache_policy" ]]; then
         zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy
     fi
 
-    if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \
-        && ! _retrieve_cache docker_subcommands;
+    if ( (( ! ${+_docker_hide_legacy_commands} )) || _cache_invalid docker_hide_legacy_commands ) \
+       && ! _retrieve_cache docker_hide_legacy_commands;
+    then
+        _docker_hide_legacy_commands="${DOCKER_HIDE_LEGACY_COMMANDS}"
+        _store_cache docker_hide_legacy_commands _docker_hide_legacy_commands
+    fi
+
+    if [[ "${_docker_hide_legacy_commands}" != "${DOCKER_HIDE_LEGACY_COMMANDS}" ]]; then
+        force_invalidation=1
+        _docker_hide_legacy_commands="${DOCKER_HIDE_LEGACY_COMMANDS}"
+        _store_cache docker_hide_legacy_commands _docker_hide_legacy_commands
+    fi
+
+    if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands ) \
+        && ! _retrieve_cache docker_subcommands || [[ ${force_invalidation} -eq 1 ]];
     then
         local -a lines
         lines=(${(f)"$(_call_program commands docker 2>&1)"})