Debian Codegraph @

src/pingpongclient.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 pingpongclient ####################################
31 _pingpongclient()
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 -poolhandle=* | \
55 -interval=* | \
56 -cspinterval=* | \
57 -cspserver=* | \
58 -loglevel=*)
59 cur="${cur#*=}"
60 return
61 ;;
62 # ====== Special case: log file =======================================
63 -logappend=* | \
64 -logfile=*)
65 cur="${cur#*=}"
66 _filedir '@(log)'
67 return
68 ;;
69 # ====== Special case: on/off =========================================
70 -logcolor=*)
71 cur="${cur#*=}"
72 mapfile -t COMPREPLY < <(compgen -W "on off" -- "${cur}")
73 return
74 ;;
75 esac
76
77 # ====== All options =====================================================
78 # Simple options without parameter(s)
79 local opts1="
80 "
81 # Options with "=" and parameter(s)
82 local opts2="
83 -poolhandle
84 -interval
85 -cspinterval
86 -cspserver
87 -logappend
88 -logcolor
89 -logfile
90 -loglevel
91 "
92 COMPREPLY=( $( compgen -W "${opts1}" -- "${cur}" )
93 $( compgen -W "${opts2}" -S "=" -- "${cur}" ) )
94 [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
95
96 return 0
97 }
98
99 complete -F _pingpongclient pingpongclient