diff --git a/plugins/scrapy/README.md b/plugins/scrapy/README.md new file mode 100644 index 000000000..bf42c4368 --- /dev/null +++ b/plugins/scrapy/README.md @@ -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 is chosen + +``` +scrapy check [tab] +dmoz +``` + +spiders are listed. \ No newline at end of file diff --git a/plugins/scrapy/_scrapy b/plugins/scrapy/_scrapy new file mode 100644 index 000000000..0d14627b7 --- /dev/null +++ b/plugins/scrapy/_scrapy @@ -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 \ No newline at end of file