mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 11:12:25 +00:00
Auto merge of #1539 - gentoo90:bash-comp, r=alexcrichton
...and restrict `--manifest-path` to propose only `*.toml` files. Also add `.gitignore` to `registry` folder
This commit is contained in:
commit
86be4e4962
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,4 +4,6 @@
|
|||
/Makefile
|
||||
/config.mk
|
||||
src/doc/build
|
||||
src/registry/target
|
||||
src/registry/Cargo.lock
|
||||
rustc
|
||||
|
|
|
@ -43,8 +43,15 @@ _cargo()
|
|||
else
|
||||
COMPREPLY=( $( compgen -W "$(cargo --list | tail -n +2)" -- "$cur" ) )
|
||||
fi
|
||||
elif [[ $cword -gt 2 && "$prev" = "$opt_mani" ]]; then
|
||||
_filedir
|
||||
elif [[ $cword -gt 2 ]]; then
|
||||
case "${prev}" in
|
||||
"$opt_mani")
|
||||
_filedir toml
|
||||
;;
|
||||
--example)
|
||||
COMPREPLY=( $( compgen -W "$(_get_examples)" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
elif [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W "${opts[$cmd]}" -- "$cur" ) )
|
||||
fi
|
||||
|
@ -56,4 +63,16 @@ _cargo()
|
|||
} &&
|
||||
complete -o nospace -F _cargo cargo
|
||||
|
||||
_locate_manifest(){
|
||||
local manifest=`cargo locate-project 2>/dev/null`
|
||||
# regexp-replace manifest '\{"root":"|"\}' ''
|
||||
echo ${manifest:9:-2}
|
||||
}
|
||||
|
||||
_get_examples(){
|
||||
local files=($(dirname $(_locate_manifest))/examples/*.rs)
|
||||
local names=("${files[@]##*/}")
|
||||
local names=("${names[@]%.*}")
|
||||
echo "${names[@]}"
|
||||
}
|
||||
# vim:ft=sh
|
||||
|
|
Loading…
Reference in a new issue