View | Details | Raw Unified | Return to bug 10003
Collapse All | Expand All

(-)a/debian/koha-common.bash-completion (+160 lines)
Line 0 Link Here
1
#!/bin/bash
2
#
3
# koha-common.bash-completion script for koha-* commands
4
#
5
# This file is part of Koha.
6
#
7
# Copyright 2013 Universidad Nacional de Cordoba
8
#                Tomas Cohen Arazi
9
#
10
# Koha is free software; you can redistribute it and/or modify it under the
11
# terms of the GNU General Public License as published by the Free Software
12
# Foundation; either version 3 of the License, or (at your option) any later
13
# version.
14
#
15
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License along
20
# with Koha; if not, see <http://www.gnu.org/licenses>.
21
22
_build_substract_switches()
23
{
24
    local substract
25
26
    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
27
        if [[ ${COMP_WORDS[i]} == -* ]]; then
28
            substract="$substract -e ${COMP_WORDS[i]}"
29
        fi
30
    done
31
32
    echo "$substract"
33
}
34
35
_koha_list_cmd()
36
{
37
    local filter=$1
38
39
    local cur substract instancelist
40
    _get_comp_words_by_ref cur
41
42
    # Build a list of the already used words
43
    substract=`_build_substract_switches`
44
45
    if [[ "$substract" != "" ]]; then
46
        instancelist=$( koha-list $filter | grep -v -x $substract )
47
    else
48
        instancelist=$( koha-list $filer )
49
    fi
50
51
    COMPREPLY=( $(compgen -W "$instancelist" -- $cur ) )
52
}
53
54
_koha_email_disable()
55
{
56
    _koha_list_cmd "--email"
57
    return 0
58
}
59
complete -F _koha_email_disable koha-email-disable
60
61
_koha_email_enable()
62
{
63
    _koha_list_cmd "--noemail"
64
    return 0
65
}
66
complete -F _koha_email_enable koha-email-enable
67
68
_koha_sip_enabled_instances()
69
{
70
    _koha_list_cmd "--sip"
71
    return 0
72
}
73
74
# koha-*-sip autocomplete with sip-enabled instances
75
complete -F _koha_sip_enabled_instances koha-start-sip
76
complete -F _koha_sip_enabled_instances koha-restart-sip
77
complete -F _koha_sip_enabled_instances koha-stop-sip
78
79
_koha_sip_disabled()
80
{
81
    _koha_list_cmd "--nosip"
82
    return 0
83
}
84
85
# koha-enable-sip autocompletes with sip-disabled instances
86
complete -F _koha_sip_disabled koha-enable-sip
87
88
_koha_disabled_instances()
89
{
90
    _koha_list_cmd "--disabled"
91
    return 0
92
}
93
94
_koha_enabled_instances()
95
{
96
    _koha_list_cmd "--enabled"
97
    return 0
98
}
99
100
# koha-enable autocompletes with disabled instances
101
complete -F _koha_disabled_instances koha-enable
102
103
# koha-disable autocompletes with enabled instances
104
complete -F _koha_enabled_instances koha-disable
105
106
# koha-*-zebra autocomplete with enabled instances
107
complete -F _koha_enabled_instances koha-start-zebra
108
complete -F _koha_enabled_instances koha-restart-zebra
109
complete -F _koha_enabled_instances koha-stop-zebra
110
111
_koha_list()
112
{
113
    local cur opts substract
114
115
    COMPREPLY=()
116
    _get_comp_words_by_ref cur
117
    opts="--enabled --disabled --email --noemail --sip --nosip --help -h"
118
119
    # Build a list of the already used option switches
120
    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
121
        if [[ ${COMP_WORDS[i]} == -* ]]; then
122
            case ${COMP_WORDS[i]} in
123
                --disabled)
124
                    substract="$substract -e --enabled"; ;;
125
                --enabled)
126
                    substract="$substract -e --disabled"; ;;
127
                --email)
128
                    substract="$substract -e --noemail"; ;;
129
                --noemail)
130
                    substract="$substract -e --email"; ;;
131
                --sip)
132
                    substract="$substract -e --nosip"; ;;
133
                --nosip)
134
                    substract="$substract -e --sip"; ;;
135
                --help)
136
                    substract="$substract -e -h"; ;;
137
                -h)
138
                    substract="$substract -e --help"; ;;
139
            esac
140
            substract="$substract -e ${COMP_WORDS[i]}"
141
        fi
142
    done
143
144
    if [[ "$substract" != "" ]]; then
145
        opts=$( echo $opts | sed -e 's/ /\n/g'  | grep -v -x $substract )
146
    fi
147
148
    COMPREPLY=( $(compgen -W "$opts" -- $cur ) )
149
150
    return 0
151
}
152
complete -F _koha_list koha-list
153
154
# Local variables:
155
# mode: shell-script
156
# sh-basic-offset: 4
157
# sh-indent-comment: t
158
# indent-tabs-mode: nil
159
# End:
160
# ex: ts=4 sw=4 et filetype=sh
(-)a/debian/rules (-2 / +1 lines)
Lines 6-12 TMP = $(CURDIR)/debian/tmp Link Here
6
export PERL_MM_USE_DEFAULT=1
6
export PERL_MM_USE_DEFAULT=1
7
7
8
%:
8
%:
9
	dh $@ --fail-missing
9
	dh $@ --fail-missing --with bash-completion
10
10
11
override_dh_gencontrol:
11
override_dh_gencontrol:
12
	debian/bd-to-depends >> debian/koha-common.substvars
12
	debian/bd-to-depends >> debian/koha-common.substvars
13
- 

Return to bug 10003