File: scrapy_bash_completion

package info (click to toggle)
python-scrapy 1.5.1-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,404 kB
  • sloc: python: 25,793; xml: 199; makefile: 95; sh: 33
file content (20 lines) | stat: -rw-r--r-- 698 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# bash completion for the Scrapy command-line tool

_scrapy_completion() {
    local cmd cur commands spiders
    cmd=${COMP_WORDS[1]}
    cur=${COMP_WORDS[2]}
    case "$cmd" in
        crawl|edit|check)
            spiders=$(scrapy list 2>/dev/null) || spiders=""
            COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W "$spiders" -- "$cur"))
        ;;
        *)
            if [ $COMP_CWORD -eq 1 ]; then
                commands="check crawl edit fetch genspider list parse runspider settings shell startproject version view"
                COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W "$commands" -- "$cmd"))
            fi
        ;;
    esac
}
complete -F _scrapy_completion -o default scrapy