suse-check-optional-dependencies.diff
[platform/upstream/rpmlint.git] / rpmlint.bash-completion
1 # bash-completion add-on for rpmlint
2 # http://bash-completion.alioth.debian.org/
3
4 _rpmlint_installed_packages()
5 {
6     if declare -F _rpm_installed_packages &>/dev/null ; then
7         _rpm_installed_packages
8     elif declare -F _xfunc &>/dev/null ; then
9         # bash-completion 1.90+ dynamic loading
10         _xfunc rpm _rpm_installed_packages
11     fi
12 }
13
14 _rpmlint()
15 {
16     COMPREPLY=()
17     local cur=$2 # for _rpm_installed_packages, _filedir
18
19     case $3 in
20         -C|--checkdir|-E|--extractdir)
21             _filedir -d
22             return 0
23             ;;
24         -f|--file|--rawout)
25             _filedir
26             return 0
27             ;;
28         -c|--check)
29             # should take --checkdir, python path, inheritance into account...
30             COMPREPLY=( $( compgen -W \
31                 "$( command ls /usr/share/rpmlint/*Check.py* 2>/dev/null |
32                     sed -e '/^AbstractCheck/d' \
33                         -e 's|.*/\([^/.]*\)\.py.*|\1|' )" -- "$cur" ) )
34             return 0
35             ;;
36         -I|--explain)
37             # should take --checkdir into account...
38             COMPREPLY=( $( compgen -W "$( sed -e '1,/^addDetails/d' \
39                 -ne "s/^'\([^'[:space:]]\{1,\}\)',\$/\1/p" \
40                 /usr/share/rpmlint/*Check.py 2>/dev/null )" -- "$cur" ) ) #'
41             return 0
42             ;;
43         -o|--option)
44             # argument required but no completions available
45             return 0
46             ;;
47     esac
48
49     if [[ "$cur" == -* ]]; then
50         COMPREPLY=( $( compgen -W '--info --explain --check --all --checkdir
51                         --help --verbose --extractdir --version --noexception
52                         --file --option' -- "$cur" ) )
53     else
54         # Installed packages completion is potentially slow, do it only if $cur
55         # does not look like a path.
56         [[ $cur != */* && $cur != [.~]* ]] && _rpmlint_installed_packages
57         _filedir @([rs]pm|spec)
58     fi
59 }
60 complete -F _rpmlint -o filenames rpmlint
61
62 _rpmdiff()
63 {
64     COMPREPLY=()
65     local cur=$2 # for _rpm_installed_packages, _filedir
66
67     case $3 in
68         -i|--ignore)
69             COMPREPLY=( $( compgen -W 'S M 5 D N L V U G F T' -- "$cur" ) )
70             return 0
71             ;;
72         -h|--help)
73             return 0
74             ;;
75     esac
76
77     if [[ "$cur" == -* ]]; then
78         COMPREPLY=( $( compgen -W '--help --ignore' -- "$cur" ) )
79     else
80         # Installed packages completion is potentially slow, do it only if $cur
81         # does not look like a path.
82         [[ $cur != */* && $cur != [.~]* ]] && _rpmlint_installed_packages
83         _filedir [rs]pm
84     fi
85 }
86 complete -F _rpmdiff -o filenames rpmdiff
87
88 # Local variables:
89 # mode: shell-script
90 # sh-basic-offset: 4
91 # sh-indent-comment: t
92 # indent-tabs-mode: nil
93 # End:
94 # ex: ts=4 sw=4 et filetype=sh