This commit is contained in:
DINESH S 2017-05-03 19:24:11 +00:00 committed by GitHub
commit 401ebae3d1
2 changed files with 75 additions and 0 deletions

33
plugins/scrapy/README.md Normal file
View file

@ -0,0 +1,33 @@
## Scrapy zsh completion
Auto completion for scrapy command-line tool
#### commands
```
$ scrapy [tab]
scrapy commands
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
```
if check/crawl/edit commands are chosen,
```
$ scrapy check [tab]
dmoz
```
spiders are listed, if you are in a scrapy project directory.

42
plugins/scrapy/_scrapy Normal file
View file

@ -0,0 +1,42 @@
#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