summaryrefslogtreecommitdiffstats
path: root/src/cli/abrt-cli.bash
blob: fd0a85f3ff16dcee41a5112d0a8235f4338e11a7 (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
# bash-completion add-on for abrt-cli(1)
# http://bash-completion.alioth.debian.org/

# $1 = additional options for abrt-cli
_abrt_list()
{
    echo $(abrt-cli --list $1 | grep UUID | awk '{print $3}')
    return 0
}

_abrt_cli()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="--help --version --list --report --delete"

    #
    #  Complete the arguments to some of the basic commands.
    #
    case "${prev}" in
        --list)
            opts="--full"
            ;;
        --report)
            # Include only not-yet-reported crashes.
            opts="--always $(_abrt_list)"
            ;;
        --always) # This is for --report --always
            # Include only not-yet-reported crashes.
            opts=$(_abrt_list)
            ;;
        --delete)
            opts=$(_abrt_list "--full")
            ;;
    esac

    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    return 0
}
complete -F _abrt_cli abrt-cli

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh