summaryrefslogtreecommitdiff
path: root/rpmlint.bash-completion
blob: 189582fff4179c312551295a4eabfb04733cb7fc (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# bash-completion add-on for rpmlint
# http://bash-completion.alioth.debian.org/

_rpmlint_installed_packages()
{
    if declare -F _rpm_installed_packages &>/dev/null ; then
        _rpm_installed_packages
    elif declare -F _xfunc &>/dev/null ; then
        # bash-completion 1.90+ dynamic loading
        _xfunc rpm _rpm_installed_packages
    fi
}

_rpmlint()
{
    COMPREPLY=()
    local cur=$2 # for _rpm_installed_packages, _filedir

    case $3 in
        -C|--checkdir|-E|--extractdir)
            _filedir -d
            return 0
            ;;
        -f|--file|--rawout)
            _filedir
            return 0
            ;;
        -c|--check)
            # should take --checkdir, python path, inheritance into account...
            COMPREPLY=( $( compgen -W \
                "$( command ls /usr/share/rpmlint/*Check.py* 2>/dev/null |
                    sed -e '/^AbstractCheck/d' \
                        -e 's|.*/\([^/.]*\)\.py.*|\1|' )" -- "$cur" ) )
            return 0
            ;;
        -I|--explain)
            # should take --checkdir into account...
            COMPREPLY=( $( compgen -W "$( sed -e '1,/^addDetails/d' \
                -ne "s/^'\([^'[:space:]]\{1,\}\)',\$/\1/p" \
                /usr/share/rpmlint/*Check.py 2>/dev/null )" -- "$cur" ) ) #'
            return 0
            ;;
        -o|--option)
            # argument required but no completions available
            return 0
            ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $( compgen -W '--info --explain --check --all --checkdir
                        --help --verbose --extractdir --version --noexception
                        --file --option' -- "$cur" ) )
    else
        # Installed packages completion is potentially slow, do it only if $cur
        # does not look like a path.
        [[ $cur != */* && $cur != [.~]* ]] && _rpmlint_installed_packages
        _filedir @([rs]pm|spec)
    fi
}
complete -F _rpmlint -o filenames rpmlint

_rpmdiff()
{
    COMPREPLY=()
    local cur=$2 # for _rpm_installed_packages, _filedir

    case $3 in
        -i|--ignore)
            COMPREPLY=( $( compgen -W 'S M 5 D N L V U G F T' -- "$cur" ) )
            return 0
            ;;
        -h|--help)
            return 0
            ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $( compgen -W '--help --ignore' -- "$cur" ) )
    else
        # Installed packages completion is potentially slow, do it only if $cur
        # does not look like a path.
        [[ $cur != */* && $cur != [.~]* ]] && _rpmlint_installed_packages
        _filedir [rs]pm
    fi
}
complete -F _rpmdiff -o filenames rpmdiff

# 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