summaryrefslogtreecommitdiffstats
path: root/completions/kcov
blob: 20a62f22c5e79fdc7699af06409f50c1a4d67bd2 (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
55
56
57
58
59
60
61
62
# kcov(1) completion                                       -*- shell-script -*-

_comp_cmd_kcov()
{
    local cur prev words cword was_split comp_args
    _comp_initialize -s -n : -- "$@" || return

    case "$prev" in
        --pid | -p)
            _comp_compgen_pids
            return
            ;;
        --sort-type | -s)
            _comp_compgen -- -W 'filename percent reverse lines uncovered'
            return
            ;;
        --include-path | --exclude-path)
            _comp_compgen_filedir
            return
            ;;
        --replace-src-path)
            if [[ $cur == ?*:* ]]; then
                _comp_compgen -c "${cur##*:}" filedir
            else
                _comp_compgen_filedir
                compopt -o nospace
            fi
            return
            ;;
        --limits | -l)
            if [[ $cur == ?*,* ]]; then
                prev="${cur%,*}"
                cur="${cur##*,}"
                _comp_compgen -- -W "{0..100}"
                ((${#COMPREPLY[@]} == 1)) &&
                    _comp_compgen -Rv COMPREPLY -- -P "$prev," -W '"$COMPREPLY"'
            else
                _comp_compgen -- -W "{0..100}"
                ((${#COMPREPLY[@]} == 1)) && COMPREPLY=("${COMPREPLY/%/,}")
                compopt -o nospace
            fi
            return
            ;;
        --title | -t | --include-pattern | --exclude-pattern | --path-strip-level)
            # argument required but no completions available
            return
            ;;
    esac

    [[ $was_split ]] && return

    if [[ $cur == -* ]]; then
        _comp_compgen_help
        [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
        return
    fi

    _comp_compgen_filedir
} &&
    complete -F _comp_cmd_kcov kcov

# ex: filetype=sh