@@ -8,9 +8,12 @@ _cargo()
8
8
9
9
cmd=${words[1]}
10
10
11
- local commands= $( cargo --list | tail -n +2 )
11
+ local vcs= ' git hg none '
12
12
13
- local opt_common=' -h --help -v --verbose'
13
+ local opt_help=' -h --help'
14
+ local opt_verbose=' -v --verbose'
15
+ local opt_quiet=' -q --quiet'
16
+ local opt_common=" $opt_help $opt_verbose $opt_quiet "
14
17
local opt_pkg=' -p --package'
15
18
local opt_feat=' --features --no-default-features'
16
19
local opt_mani=' --manifest-path'
@@ -30,33 +33,36 @@ _cargo()
30
33
local opt__owner=" $opt_common -a --add -r --remove -l --list --index --token"
31
34
local opt__pkgid=" ${opt__fetch} "
32
35
local opt__publish=" $opt_common $opt_mani --host --token --no-verify"
33
- local opt__read_manifest=" ${opt__fetch} "
36
+ local opt__read_manifest=" $opt_help $opt_verbose $opt_mani "
34
37
local opt__run=" $opt_common $opt_feat $opt_mani $opt_jobs --target --bin --example --release"
35
38
local opt__rustc=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --release"
36
39
local opt__search=" $opt_common --host"
37
40
local opt__test=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --no-run --release"
38
41
local opt__update=" $opt_common $opt_pkg $opt_mani --aggressive --precise"
39
42
local opt__package=" $opt_common $opt_mani -l --list --no-verify --no-metadata"
40
43
local opt__verify_project=" ${opt__fetch} "
41
- local opt__version=" $opt_common "
44
+ local opt__version=" $opt_help $opt_verbose "
42
45
local opt__yank=" $opt_common --vers --undo --index --token"
43
46
44
47
if [[ $cword -eq 1 ]]; then
45
48
if [[ " $cur " == -* ]]; then
46
49
COMPREPLY=( $( compgen -W " ${opt___nocmd} " -- " $cur " ) )
47
50
else
48
- COMPREPLY=( $( compgen -W " $commands " -- " $cur " ) )
51
+ COMPREPLY=( $( compgen -W " $__cargo_commands " -- " $cur " ) )
49
52
fi
50
53
elif [[ $cword -ge 2 ]]; then
51
54
case " ${prev} " in
55
+ --vcs)
56
+ COMPREPLY=( $( compgen -W " $vcs " -- " $cur " ) )
57
+ ;;
52
58
--manifest-path)
53
59
_filedir toml
54
60
;;
55
61
--example)
56
62
COMPREPLY=( $( compgen -W " $( _get_examples) " -- " $cur " ) )
57
63
;;
58
64
help)
59
- COMPREPLY=( $( compgen -W " $commands " -- " $cur " ) )
65
+ COMPREPLY=( $( compgen -W " $__cargo_commands " -- " $cur " ) )
60
66
;;
61
67
* )
62
68
local opt_var=opt__${cmd// -/ _}
@@ -71,6 +77,8 @@ _cargo()
71
77
} &&
72
78
complete -F _cargo cargo
73
79
80
+ __cargo_commands=$( cargo --list | tail -n +2)
81
+
74
82
_locate_manifest (){
75
83
local manifest=` cargo locate-project 2> /dev/null`
76
84
# regexp-replace manifest '\{"root":"|"\}' ''
0 commit comments