@@ -10,6 +10,7 @@ _cargo()
10
10
11
11
local vcs=' git hg none'
12
12
local color=' auto always never'
13
+ local msg_format=' human json'
13
14
14
15
local opt_help=' -h --help'
15
16
local opt_verbose=' -v --verbose'
@@ -20,38 +21,41 @@ _cargo()
20
21
local opt_feat=' --features --all-features --no-default-features'
21
22
local opt_mani=' --manifest-path'
22
23
local opt_jobs=' -j --jobs'
24
+ local opt_force=' -f --force'
25
+ local opt_test=' --test --bench'
26
+ local opt_lock=' --frozen --locked'
23
27
24
28
local opt___nocmd=" $opt_common -V --version --list"
25
- local opt__bench=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --no-run"
26
- local opt__build=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --release"
27
- local opt__check=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs -- target --lib --bin --example"
28
- local opt__clean=" $opt_common $opt_pkg $opt_mani --target --release"
29
- local opt__doc=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --open --no-deps --release"
30
- local opt__fetch=" $opt_common $opt_mani "
29
+ local opt__bench=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $ opt_jobs $opt_test --message-format --target --lib --bin --example --no-run"
30
+ local opt__build=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $ opt_jobs $opt_test --message-format --target --lib --bin --example --release"
31
+ local opt__check=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $ opt_jobs $opt_test --message-format -- target --lib --bin --example --release "
32
+ local opt__clean=" $opt_common $opt_pkg $opt_mani $opt_lock --target --release"
33
+ local opt__doc=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $ opt_jobs --message-format --bin --lib --target --open --no-deps --release"
34
+ local opt__fetch=" $opt_common $opt_mani $opt_lock "
31
35
local opt__generate_lockfile=" ${opt__fetch} "
32
- local opt__git_checkout=" $opt_common --reference --url"
36
+ local opt__git_checkout=" $opt_common $opt_lock --reference --url"
33
37
local opt__help=" $opt_help "
34
- local opt__init=" $opt_common --bin --name --vcs"
35
- local opt__install=" $opt_common $opt_feat $opt_jobs --bin --branch --debug --example --git --list --path --rev --root --tag --vers"
38
+ local opt__init=" $opt_common $opt_lock --bin --lib --name --vcs"
39
+ local opt__install=" $opt_common $opt_feat $opt_jobs $opt_lock $opt_force --bin --branch --debug --example --git --list --path --rev --root --tag --vers"
36
40
local opt__locate_project=" $opt_mani -h --help"
37
- local opt__login=" $opt_common --host"
38
- local opt__metadata=" $opt_common $opt_feat $opt_mani --format-version"
39
- local opt__new=" $opt_common --vcs --bin --name"
40
- local opt__owner=" $opt_common -a --add -r --remove -l --list --index --token"
41
- local opt__package=" $opt_common $opt_mani -l --list --no-verify --no-metadata"
42
- local opt__pkgid=" ${opt__fetch} "
43
- local opt__publish=" $opt_common $opt_mani --host --token --no-verify"
44
- local opt__read_manifest=" $opt_help $opt_verbose $opt_mani $opt_color "
45
- local opt__run=" $opt_common $opt_feat $opt_mani $opt_jobs --target --bin --example --release"
46
- local opt__rustc=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --release"
47
- local opt__rustdoc=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --release --open"
48
- local opt__search=" $opt_common --host"
49
- local opt__test=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --no-run --release --no-fail-fast"
50
- local opt__uninstall=" $opt_common --bin --root"
51
- local opt__update=" $opt_common $opt_pkg $opt_mani --aggressive --precise"
41
+ local opt__login=" $opt_common $opt_lock --host"
42
+ local opt__metadata=" $opt_common $opt_feat $opt_mani $opt_lock --format-version --no-deps "
43
+ local opt__new=" $opt_common $opt_lock --vcs --bin --lib --name"
44
+ local opt__owner=" $opt_common $opt_lock -a --add -r --remove -l --list --index --token"
45
+ local opt__package=" $opt_common $opt_mani $opt_lock $opt_jobs --allow-dirty -l --list --no-verify --no-metadata"
46
+ local opt__pkgid=" ${opt__fetch} $opt_pkg "
47
+ local opt__publish=" $opt_common $opt_mani $opt_lock $opt_jobs --allow-dirty --dry-run --host --token --no-verify"
48
+ local opt__read_manifest=" $opt_help $opt_verbose $opt_mani $opt_color --no-deps "
49
+ local opt__run=" $opt_common $opt_feat $opt_mani $opt_lock $ opt_jobs --message-format --target --bin --example --release"
50
+ local opt__rustc=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $ opt_jobs $opt_test --message-format --profile --target --lib --bin --example --release"
51
+ local opt__rustdoc=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $ opt_jobs $opt_test --message-format --target --lib --bin --example --release --open"
52
+ local opt__search=" $opt_common $opt_lock --host --limit "
53
+ local opt__test=" $opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $ opt_jobs $opt_test --message-format --all --doc --target --lib --bin --example --no-run --release --no-fail-fast"
54
+ local opt__uninstall=" $opt_common $opt_lock --bin --root"
55
+ local opt__update=" $opt_common $opt_pkg $opt_mani $opt_lock --aggressive --precise"
52
56
local opt__verify_project=" ${opt__fetch} "
53
57
local opt__version=" $opt_help $opt_verbose $opt_color "
54
- local opt__yank=" $opt_common --vers --undo --index --token"
58
+ local opt__yank=" $opt_common $opt_lock --vers --undo --index --token"
55
59
56
60
if [[ $cword -eq 1 ]]; then
57
61
if [[ " $cur " == -* ]]; then
@@ -67,6 +71,9 @@ _cargo()
67
71
--color)
68
72
COMPREPLY=( $( compgen -W " $color " -- " $cur " ) )
69
73
;;
74
+ --message-format)
75
+ COMPREPLY=( $( compgen -W " $msg_format " -- " $cur " ) )
76
+ ;;
70
77
--manifest-path)
71
78
_filedir toml
72
79
;;
@@ -113,55 +120,55 @@ _locate_manifest(){
113
120
# command line options for completion
114
121
_get_names_from_array ()
115
122
{
116
- local manifest=$( _locate_manifest)
117
- if [[ -z $manifest ]]; then
118
- return 0
119
- fi
120
-
121
- local last_line
122
- local -a names
123
- local in_block=false
124
- local block_name=$1
125
- while read line
126
- do
127
- if [[ $last_line == " [[$block_name ]]" ]]; then
128
- in_block=true
129
- else
130
- if [[ $last_line =~ .* \[\[ .* ]]; then
131
- in_block=false
132
- fi
133
- fi
134
-
135
- if [[ $in_block == true ]]; then
136
- if [[ $line =~ .* name.* \= ]]; then
137
- line=${line##* =}
138
- line=${line%% \" }
139
- line=${line##* \" }
140
- names+=($line )
141
- fi
142
- fi
143
-
144
- last_line=$line
145
- done < $manifest
146
- echo " ${names[@]} "
123
+ local manifest=$( _locate_manifest)
124
+ if [[ -z $manifest ]]; then
125
+ return 0
126
+ fi
127
+
128
+ local last_line
129
+ local -a names
130
+ local in_block=false
131
+ local block_name=$1
132
+ while read line
133
+ do
134
+ if [[ $last_line == " [[$block_name ]]" ]]; then
135
+ in_block=true
136
+ else
137
+ if [[ $last_line =~ .* \[\[ .* ]]; then
138
+ in_block=false
139
+ fi
140
+ fi
141
+
142
+ if [[ $in_block == true ]]; then
143
+ if [[ $line =~ .* name.* \= ]]; then
144
+ line=${line##* =}
145
+ line=${line%% \" }
146
+ line=${line##* \" }
147
+ names+=($line )
148
+ fi
149
+ fi
150
+
151
+ last_line=$line
152
+ done < $manifest
153
+ echo " ${names[@]} "
147
154
}
148
155
149
156
# Gets the bin names from the manifest file
150
157
_bin_names ()
151
158
{
152
- _get_names_from_array " bin"
159
+ _get_names_from_array " bin"
153
160
}
154
161
155
162
# Gets the test names from the manifest file
156
163
_test_names ()
157
164
{
158
- _get_names_from_array " test"
165
+ _get_names_from_array " test"
159
166
}
160
167
161
168
# Gets the bench names from the manifest file
162
169
_benchmark_names ()
163
170
{
164
- _get_names_from_array " bench"
171
+ _get_names_from_array " bench"
165
172
}
166
173
167
174
_get_examples (){
@@ -188,16 +195,16 @@ _get_targets(){
188
195
local FIND_PATHS=( " /" )
189
196
local FIND_PATH LINES LINE
190
197
while [[ " $CURRENT_PATH " != " /" ]]; do
191
- FIND_PATHS+=( " $CURRENT_PATH " )
192
- CURRENT_PATH=$( dirname $CURRENT_PATH )
198
+ FIND_PATHS+=( " $CURRENT_PATH " )
199
+ CURRENT_PATH=$( dirname $CURRENT_PATH )
193
200
done
194
201
for FIND_PATH in ${FIND_PATHS[@]} ; do
195
- if [[ -f " $FIND_PATH " /.cargo/config ]]; then
202
+ if [[ -f " $FIND_PATH " /.cargo/config ]]; then
196
203
LINES=( ` grep " $FIND_PATH " /.cargo/config -e " ^\[target\." ` )
197
204
for LINE in ${LINES[@]} ; do
198
- TARGETS+=(` sed ' s/^\[target\.\(.*\)\]$/\1/' <<< $LINE ` )
205
+ TARGETS+=(` sed ' s/^\[target\.\(.*\)\]$/\1/' <<< $LINE ` )
199
206
done
200
- fi
207
+ fi
201
208
done
202
209
echo " ${TARGETS[@]} "
203
210
}
0 commit comments