mirror of https://github.com/docker/cli.git
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>
This commit is contained in:
parent
536f41a73e
commit
69d7e8443d
|
@ -177,7 +177,9 @@ __docker_commands () {
|
||||||
if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \
|
if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \
|
||||||
&& ! _retrieve_cache docker_subcommands;
|
&& ! _retrieve_cache docker_subcommands;
|
||||||
then
|
then
|
||||||
_docker_subcommands=(${${${${(f)"$(_call_program commands docker 2>&1)"}[5,-1]}## #}/ ##/:})
|
local -a lines
|
||||||
|
lines=(${(f)"$(_call_program commands docker 2>&1)"})
|
||||||
|
_docker_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
|
||||||
_docker_subcommands=($_docker_subcommands 'help:Show help for a command')
|
_docker_subcommands=($_docker_subcommands 'help:Show help for a command')
|
||||||
_store_cache docker_subcommands _docker_subcommands
|
_store_cache docker_subcommands _docker_subcommands
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue