3
3
autoload -U regexp-replace
4
4
5
5
_cargo() {
6
- local context state state_descr line
6
+ local state
7
7
typeset -A opt_args
8
8
9
9
# leading items in parentheses are an exclusion list for the arguments following that arg
@@ -26,7 +26,7 @@ _cargo() {
26
26
27
27
case $state in
28
28
args)
29
- case $words[1] in
29
+ case ${ words[1]} in
30
30
bench)
31
31
_arguments \
32
32
'--features=[space separated feature list]' \
@@ -430,20 +430,20 @@ _cargo_cmds() {
430
430
#FIXME: Disabled until fixed
431
431
#gets package names from the manifest file
432
432
_get_package_names() {
433
+ :
433
434
}
434
435
435
436
#TODO:see if it makes sense to have 'locate-project' to have non-json output.
436
437
#strips package name from json stuff
437
438
_locate_manifest() {
438
439
local manifest=$(cargo locate-project 2>/dev/null)
439
440
regexp-replace manifest '\{"root":"|"\}' ''
440
- echo $manifest
441
+ echo " $manifest"
441
442
}
442
443
443
444
# Extracts the values of "name" from the array given in $1 and shows them as
444
445
# command line options for completion
445
446
_get_names_from_array() {
446
- local -a filelist;
447
447
local manifest=$(_locate_manifest)
448
448
if [[ -z $manifest ]]; then
449
449
return 0
@@ -454,26 +454,25 @@ _get_names_from_array() {
454
454
local in_block=false
455
455
local block_name=$1
456
456
names=()
457
- while read line
458
- do
457
+ while read -r line; do
459
458
if [[ $last_line == "[[$block_name]]" ]]; then
460
459
in_block=true
461
460
else
462
- if [[ $last_line =~ '. *\[\[.*' ]]; then
461
+ if [[ $last_line =~ '\s *\[\[.*' ]]; then
463
462
in_block=false
464
463
fi
465
464
fi
466
465
467
466
if [[ $in_block == true ]]; then
468
- if [[ $line =~ '. *name. *=' ]]; then
469
- regexp-replace line '^. *name *= *|"' ""
470
- names+=$line
467
+ if [[ $line =~ '\s *name\s *=' ]]; then
468
+ regexp-replace line '^\s *name\s*=\s *|"' ''
469
+ names+=( " $line" )
471
470
fi
472
471
fi
473
472
474
473
last_line=$line
475
- done < $manifest
476
- _describe $block_name names
474
+ done < " $manifest"
475
+ _describe " $block_name" names
477
476
478
477
}
479
478
0 commit comments