summaryrefslogtreecommitdiff
path: root/bash-completion/addons/bootadm
blob: 89963af14968901d5614bd4447b737121ec81ea4 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
_bootadm () {
    local cur prev opts line
    COMPREPLY=()

    cur=${COMP_WORDS[COMP_CWORD]}
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    line="${COMP_LINE}"

    if [[ ${COMP_CWORD} -eq 1 ]]; then
        COMPREPLY=( $(compgen -W "update-archive list-archive set-menu list-menu" -- $cur) )
        return
    fi

    case "$prev" in
    -R)
        _cd
        return;;
    -p)
        COMPREPLY=( $(compgen -W "i86pc sun4v sun4u" -- $cur) )
        return;;
    list-menu)
        COMPREPLY=( $(compgen -W "-R" -- $cur) )
        return;;
    esac

    case "$line" in
    *update-archive*-R*)
        COMPREPLY=( $(compgen -W "-v -n -f -F -p" -- $cur) )
        ;;
    *update-archive*)
        COMPREPLY=( $(compgen -W "-v -n -f -F -R" -- $cur) )
        ;;
    *list-archive*-R*)
        COMPREPLY=( $(compgen -W "-p" -- $cur) )
        ;;
    *list-archive*)
        COMPREPLY=( $(compgen -W "-R" -- $cur) )
        ;;
    *set-menu*-R*)
        COMPREPLY=( $(compgen -W "default= timeout=" -- $cur) )
        compopt -o nospace
        ;;
    *set-menu*)
        COMPREPLY=( $(compgen -W "-R default= timeout=" -- $cur) )
        if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != -R ]]; then
            compopt -o nospace
        fi
        ;;
    esac

}

complete -F _bootadm bootadm