ohmyzsh/plugins/scrapy/_scrapy
2015-04-05 23:27:32 +05:30

42 lines
No EOL
1.2 KiB
Text

#compdef scrapy
# zsh completion for the Scrapy command-line tool
_scrapy() {
local curcontext="$curcontext" cmd spiders
typeset -A opt_args
cmd=$words[2]
local -a _1st_arguments
_1st_arguments=(
"check":"Check spider contracts",
"crawl":"Run a spider",
"edit":"Edit spider",
"fetch":"Fetch a URL using the Scrapy downloader",
"genspider":"Generate new spider using pre-defined templates",
"list":"List available spiders",
"parse":"Parse URL (using its spider) and print the results",
"runspider":"Run a self-contained spider (without creating a project)",
"settings":"Get settings values",
"shell":"Interactive scraping console",
"startproject":"Create new project",
"version":"Print Scrapy version",
"view":"Open URL in browser, as seen by Scrapy"
)
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
_describe -t commands "scrapy commands" _1st_arguments
fi
;;
esac
}
_scrapy