Debian Codegraph @

src/rspserver.bash-completion

raw
1 # shellcheck shell=bash
2 # --------------------------------------------------------------------------
3 #
4 # //===// //===== //===// // // //===//
5 # // // // // // // // // //
6 # //===// //===== //===// // // //===<<
7 # // \\ // // // // // //
8 # // \\ =====// // //===== // //===// Version III
9 #
10 # ------------- An Efficient RSerPool Prototype Implementation -------------
11 #
12 # Copyright (C) 2002-2026 by Thomas Dreibholz
13 #
14 # This program is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #
27 # Contact: [email protected]
28
29
30 # ###### Bash completion for rspserver #####################################
31 _rspserver()
32 {
33 # Based on: https://www.benningtons.net/index.php/bash-completion/
34 local cur prev words cword
35 if type -t _comp_initialize >/dev/null; then
36 _comp_initialize -n = || return
37 elif type -t _init_completion >/dev/null; then
38 _init_completion -n = || return
39 else
40 # Manual initialization for older bash completion versions:
41 COMPREPLY=()
42 cur="${COMP_WORDS[COMP_CWORD]}"
43 # shellcheck disable=SC2034
44 prev="${COMP_WORDS[COMP_CWORD-1]}"
45 # shellcheck disable=SC2034,SC2124
46 words="${COMP_WORDS[@]}"
47 # shellcheck disable=SC2034
48 cword="${COMP_CWORD}"
49 fi
50
51 # ====== Parameters ======================================================
52 case "${cur}" in
53 # ====== Generic value ===============================================
54 -local=* | \
55 -asapannounce=* | \
56 -identifier=* | \
57 -poolhandle=* | \
58 -registrar=* | \
59 -rereginterval=* | \
60 -runtime=* | \
61 -uptime=* | \
62 -downtime=* | \
63 -loglevel=* | \
64 -cspserver=* | \
65 -cspinterval=* | \
66 -capcapacity=* | \
67 -capcleanshutdownprobability=* | \
68 -capcookiemaxcalculations=* | \
69 -capcookiemaxtime=* | \
70 -capkeepalivetransmissioninterval=* | \
71 -capkeepalivetimeoutinterval=* | \
72 -capmaxjobs=* | \
73 -capobject=* | \
74 -fgpcookiemaxpackets=* | \
75 -fgpcookiemaxtime=* | \
76 -fgpfailureafter=* | \
77 -fgptransmittimeout=* | \
78 -pppfailureafter=* | \
79 -sskeyring=* | \
80 -sstrustdb=* | \
81 -sscachedirectory=* | \
82 -sscachemaxentries=* | \
83 -sscachemaxsize=* | \
84 -sskeepaliveinterval=* | \
85 -sskeepalivetimeout=* | \
86 -sstransmittimeout=*)
87 cur="${cur#*=}"
88 return
89 ;;
90 # ====== Special case: pool policy ====================================
91 -policy=*)
92 cur="${cur#*=}"
93 local policies="
94 LeastUsed
95 LeastUsedDegradation
96 LeastUsedDegradationDPF
97 LeastUsedDPF
98 Priority
99 PriorityLeastUsed
100 PriorityLeastUsedDegradation
101 PriorityLeastUsedDegradationDPF
102 PriorityLeastUsedDPF
103 Random
104 RandomizedLeastUsed
105 RandomizedLeastUsedDegradation
106 RandomizedPriorityLeastUsed
107 RandomizedPriorityLeastUsedDegradation
108 RoundRobin
109 WeightedRandom
110 WeightedRandomDPF
111 WeightedRoundRobin
112 "
113 mapfile -t COMPREPLY < <(compgen -W "${policies}" -- "${cur}")
114 return
115 ;;
116 # ====== Special case: number of cores ================================
117 -chargenmaxthreads=* | \
118 -fgpmaxthreads=* | \
119 -pppmaxthreads=* | \
120 -ssmaxthreads=*)
121 cur="${cur#*=}"
122 mapfile -t COMPREPLY < <(compgen -W "$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -a | grep 'hw.ncpu' | cut -d ':' -f2 | tr -d ' ' || echo "1")" -- "${cur}")
123 return
124 ;;
125 # ====== Special case: scalar file ====================================
126 -capscalar=*)
127 cur="${cur#*=}"
128 _filedir '@(sca)'
129 return
130 ;;
131 # ====== Special case: vector file ====================================
132 -capvector=*)
133 cur="${cur#*=}"
134 _filedir '@(vec)'
135 return
136 ;;
137 # ====== Special case: log file =======================================
138 -logappend=* | \
139 -logfile=*)
140 cur="${cur#*=}"
141 _filedir '@(log)'
142 return
143 ;;
144 # ====== Special case: on/off =========================================
145 -logcolor=*)
146 cur="${cur#*=}"
147 mapfile -t COMPREPLY < <(compgen -W "on off" -- "${cur}")
148 return
149 ;;
150 esac
151
152 # ====== All options =====================================================
153 # Simple options without parameter(s)
154 local opts1="
155 -quiet
156 -calcapp
157 -chargen
158 -daytime
159 -discard
160 -echo
161 -fractal
162 -fgptestmode
163 -pingpong
164 -scripting
165 -sskeeptempdirs
166 "
167 # Options with "=" and parameter(s)
168 local opts2="
169 -local
170 -asapannounce
171 -identifier
172 -policy
173 -poolhandle
174 -registrar
175 -rereginterval
176 -runtime
177 -uptime
178 -downtime
179 -logcolor
180 -logappend
181 -logfile
182 -loglevel
183 -cspserver
184 -cspinterval
185 -capcapacity
186 -capcleanshutdownprobability
187 -capcookiemaxcalculations
188 -capcookiemaxtime
189 -capkeepalivetransmissioninterval
190 -capkeepalivetimeoutinterval
191 -capmaxjobs
192 -capobject
193 -capscalar
194 -capvector
195 -chargenmaxthreads
196 -fgpcookiemaxpackets
197 -fgpcookiemaxtime
198 -fgpfailureafter
199 -fgpmaxthreads
200 -fgptransmittimeout
201 -pppfailureafter
202 -pppmaxthreads
203 -sskeyring
204 -sstrustdb
205 -sscachedirectory
206 -sscachemaxentries
207 -sscachemaxsize
208 -sskeepaliveinterval
209 -sskeepalivetimeout
210 -ssmaxthreads
211 -sstransmittimeout
212 "
213 COMPREPLY=( $( compgen -W "${opts1}" -- "${cur}" )
214 $( compgen -W "${opts2}" -S "=" -- "${cur}" ) )
215 [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
216
217 return 0
218 }
219
220 complete -F _rspserver rspserver