2
2
3
3
autoload -U regexp-replace
4
4
5
- zstyle -T ':completion:*:*:cargo:*' tag-order && \
6
- zstyle ':completion:*:*:cargo:*' tag-order 'common-commands'
7
-
8
5
_cargo() {
9
6
local context state state_descr line
10
7
typeset -A opt_args
@@ -24,14 +21,10 @@ _arguments \
24
21
'(+beta +nightly)+stable[use the stable toolchain]' \
25
22
'(+stable +nightly)+beta[use the beta toolchain]' \
26
23
'(+stable +beta)+nightly[use the nightly toolchain]' \
27
- '1: :->command ' \
24
+ '1: :_cargo_cmds ' \
28
25
'*:: :->args'
29
26
30
27
case $state in
31
- command)
32
- _alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds'
33
- ;;
34
-
35
28
args)
36
29
case $words[1] in
37
30
bench)
@@ -426,44 +419,9 @@ esac
426
419
}
427
420
428
421
_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
467
425
}
468
426
469
427
0 commit comments