Debian Codegraph @

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