bash_completion.bash 1.54 KB
Newer Older
1 2 3 4 5
_lein_completion() {
    local cur prev tasks
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
6
    tasks="change check classpath clean compile deploy deps do help install jar javac new plugin pom release repl retest run search show-profiles test trampoline uberjar update-in upgrade vcs version with-profile"
7 8

    case "${prev}" in
9
        change | check | classpath | clean | deploy | deps | do | install | jar | javac | new | plugin | pom | release | repl | show-profiles | uberjar | update-in | vcs | version)
10 11 12 13 14 15 16 17 18 19 20
            COMPREPLY=()
            ;;
        help)
            # Show tasks again, but only once; don't infinitely recurse
            local prev2="${COMP_WORDS[COMP_CWORD-2]}"
            if [ "$prev2" == "help" ]; then
                COMPREPLY=()
            else
                COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
            fi
            ;;
21
        test | retest )
22
            # list project's test namespaces:
23
            local namespaces=$(find test/ -type f -name "*.clj" -exec sed -n 's/^(ns[ ]*//p' '{}' '+')
24 25
            COMPREPLY=( $(compgen -W "${namespaces}" -- ${cur}) )
            ;;
26 27
        run | compile)
            # list project's src namespaces:
28
            local namespaces=$(find src/ -type f -name "*.clj" -exec sed -n 's/^(ns[ ]*//p' '{}' '+')
29 30
            COMPREPLY=( $(compgen -W "${namespaces}" -- ${cur}) )
            ;;
31 32 33 34 35 36 37 38
        lein)
            COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
            ;;
    esac

    return 0
}
complete -F _lein_completion lein