File: bash_completion.module-build

package info (click to toggle)
libmodule-build-perl 0.422000-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,516 kB
  • ctags: 1,083
  • sloc: perl: 11,174; sh: 44; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Module::Build Bash completion function
# Contributed by Julian Mehnle <julian@mehnle.net>
# $Id$
# vim:syn=sh

if
    actions=$(
        perl -M'Module::Build' -le 'print foreach Module::Build->known_actions' 2>/dev/null
    ) && 
    properties=$(
        perl -M'Module::Build' -le 'print foreach sort Module::Build->valid_properties' 2>/dev/null
    )
then
    eval "_Build_actions () { echo '$actions'; }"
    eval "_Build_properties () { echo '$properties'; }"
    unset -v actions properties
    
    _Build () {
        local word=${COMP_WORDS[COMP_CWORD]}
        #local prev_word=${COMP_WORDS[COMP_CWORD-1]}
        #local action=${COMP_WORDS[1]}
        
        if (( $COMP_CWORD == 1 )); then
            # Complete actions:
            local IFS_org="$IFS"
            IFS=$'\x1F\t\n'
                # Avoid space (\x20) as a word separator to make the following -S ' ' work.
            COMPREPLY=($( compgen -W "$(_Build_actions)" -S ' ' -- "$word" ))
            IFS="$IFS_org"
        else
            # Complete properties:
            COMPREPLY=($( compgen -W "$(_Build_properties)" -S = -- "$word" ))
        fi
        
        return 0
    }
    
    complete -o nospace -F _Build Build
fi