Skip to content

Commit dab1913

Browse files
committed
zsh completion: Pull list of commands from cargo --list
The list given by `cargo --list` contains the command descriptions, too. It's better to keep only one place to be in sync with changes. This commit reverts a8ed44c.
1 parent 5a0c31d commit dab1913

File tree

1 file changed

+4
-46
lines changed

1 file changed

+4
-46
lines changed

src/etc/_cargo

+4-46
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
autoload -U regexp-replace
44

5-
zstyle -T ':completion:*:*:cargo:*' tag-order && \
6-
zstyle ':completion:*:*:cargo:*' tag-order 'common-commands'
7-
85
_cargo() {
96
local context state state_descr line
107
typeset -A opt_args
@@ -24,14 +21,10 @@ _arguments \
2421
'(+beta +nightly)+stable[use the stable toolchain]' \
2522
'(+stable +nightly)+beta[use the beta toolchain]' \
2623
'(+stable +beta)+nightly[use the nightly toolchain]' \
27-
'1: :->command' \
24+
'1: :_cargo_cmds' \
2825
'*:: :->args'
2926

3027
case $state in
31-
command)
32-
_alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds'
33-
;;
34-
3528
args)
3629
case $words[1] in
3730
bench)
@@ -426,44 +419,9 @@ esac
426419
}
427420

428421
_cargo_cmds(){
429-
local -a commands;commands=(
430-
'bench:execute all benchmarks of a local package'
431-
'build:compile the current package'
432-
'check:check the current package without compiling'
433-
'clean:remove generated artifacts'
434-
'doc:build package documentation'
435-
'fetch:fetch package dependencies'
436-
'generate-lockfile:create lockfile'
437-
'git-checkout:git checkout'
438-
'help:get help for commands'
439-
'init:create new package in current directory'
440-
'install:install a Rust binary'
441-
'locate-project:print "Cargo.toml" location'
442-
'login:login to remote server'
443-
'metadata:the metadata for a package in json'
444-
'new:create a new package'
445-
'owner:manage the owners of a crate on the registry'
446-
'package:assemble local package into a distributable tarball'
447-
'pkgid:print a fully qualified package specification'
448-
'publish:upload package to the registry'
449-
'read-manifest:print manifest in JSON format'
450-
'run:run the main binary of the local package'
451-
'rustc:compile a package and all of its dependencies'
452-
'rustdoc:build documentation for a package'
453-
'search:search packages on crates.io'
454-
'test:execute all unit and tests of a local package'
455-
'uninstall:remove a Rust binary'
456-
'update:update dependencies'
457-
'verify-project:check Cargo.toml'
458-
'version:show version information'
459-
'yank:remove pushed file from index'
460-
)
461-
_describe -t common-commands 'common commands' commands
462-
}
463-
464-
_cargo_all_cmds(){
465-
local -a commands;commands=($(cargo --list))
466-
_describe -t all-commands 'all commands' commands
422+
local -a commands
423+
commands=( ${${${(M)"${(f)$(cargo --list)}":# *}/ ##/}/ ##/:} )
424+
_describe 'command' commands
467425
}
468426

469427

0 commit comments

Comments
 (0)