Browse code

zsh: correctly parse available subcommands

A lot of flags have been added on the output of `docker help`. Use a
more robust method to extract the list of available subcommands by
spotting the `Command:` line and the next blank line.

Signed-off-by: Vincent Bernat <vincent@bernat.im>

Vincent Bernat authored on 2014/11/23 08:45:14
Showing 1 changed files
... ...
@@ -177,7 +177,9 @@ __docker_commands () {
177 177
     if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \
178 178
         && ! _retrieve_cache docker_subcommands;
179 179
     then
180
-        _docker_subcommands=(${${${${(f)"$(_call_program commands docker 2>&1)"}[5,-1]}## #}/ ##/:})
180
+        local -a lines
181
+        lines=(${(f)"$(_call_program commands docker 2>&1)"})
182
+        _docker_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I)    *]}]}## #}/ ##/:})
181 183
         _docker_subcommands=($_docker_subcommands 'help:Show help for a command')
182 184
         _store_cache docker_subcommands _docker_subcommands
183 185
     fi