Added zsh completion for the Scrapy command-line tool

This commit is contained in:
dinesh 2014-11-02 22:24:00 +05:30
parent fcf97001a5
commit 9d0ea5a396
2 changed files with 26 additions and 0 deletions

View File

@ -1 +1,2 @@
extras/scrapy_bash_completion etc/bash_completion.d/
extras/_scrapy_zsh_completion /usr/local/share/zsh/site-functions/

View File

@ -0,0 +1,25 @@
#compdef scrapy
# zsh completion for the Scrapy command-line tool
_scrapy() {
local curcontext="$curcontext" cmd spiders
typeset -A opt_args
cmd=$words[2]
case "$cmd" in
crawl|edit|check)
spiders=$(scrapy list 2>/dev/null) || spiders=""
if [[ -n "$spiders" ]]; then
compadd `echo $spiders`
fi
;;
*)
if [[ CURRENT -eq 2 ]]; then
_arguments '*: :(check crawl deploy edit fetch genspider list parse runspider server settings shell startproject version view)'
fi
;;
esac
}
_scrapy