summaryrefslogtreecommitdiffstats
path: root/debian/thunderbird.bash-completion
blob: e61cb109467c0eea7414162ce8e7f44a0f83f307 (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
63
64
65
# bash completion for thunderbird(1)                    -*- shell-script -*-
#
# Copyright (C) 2017 Carsten Schoenert <c.schoenert@t-online.de>

_thunderbird() {
local cur prev OPTS FLAG_FIXMIME FLAG_SHOW_BACKUP
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
OPTS="--fixmime --help --show-backup -g --verbose"

case $prev in
    '--fixmime')
        # Check if '--verbose' is already given, this is the  only option that
        # '--fixmime' should be combined
        if [ ! $(compgen -W "${COMP_WORDS[*]}" -- "--verbose") ]; then
            COMPREPLY=( $(compgen -W "--verbose" -- $cur) )
        fi
        return 0
        ;;

    '--help'|'-g')
        return 0
        ;;

    '--show-backup')
        # Check if '--verbose' is already given, this is the only option that
        # --show-backup should be combined
        if [ ! $(compgen -W "${COMP_WORDS[*]}" -- "--verbose") ]; then
            COMPREPLY=( $(compgen -W "--verbose" -- $cur) )
        fi
        return 0
        ;;

    '--verbose')
        FLAG_FIXMIME=""
        FLAG_SHOW_BACKUP=""

        # Check if '--fixmime' is already given
        if [ $(compgen -W "${COMP_WORDS[*]}" -- "--fixmime") ]; then
            # Yes, we have seen '-fixmime'
            FLAG_FIXMIME=1
        fi

        # Check if '--show-backup' is already given
        if [ $(compgen -W "${COMP_WORDS[*]}" -- "--show-backup") ]; then
            # Yes, we have seen '--show-backup'
            FLAG_SHOW_BACKUP=1
        fi

        if [ "$FLAG_FIXMIME" != "1" ] && [ "$FLAG_SHOW_BACKUP" != "1" ]; then
            COMPREPLY=( $(compgen -W "--fixmime --show-backup" -- $cur) )
        fi
        return 0
        ;;

esac

    COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
    return 0

} &&
complete -F _thunderbird thunderbird

# ex: ts=4 sw=4 et filetype=sh