Debian Codegraph @

src/hipercontracer.bash-completion

raw
1 # shellcheck shell=bash
2 # ==========================================================================
3 # _ _ _ ____ ____ _____
4 # | | | (_) _ \ ___ _ __ / ___|___ _ _|_ _| __ __ _ ___ ___ _ __
5 # | |_| | | |_) / _ \ '__| | / _ \| '_ \| || '__/ _` |/ __/ _ \ '__|
6 # | _ | | __/ __/ | | |__| (_) | | | | || | | (_| | (_| __/ |
7 # |_| |_|_|_| \___|_| \____\___/|_| |_|_||_| \__,_|\___\___|_|
8 #
9 # --- High-Performance Connectivity Tracer (HiPerConTracer) ---
10 # https://www.nntb.no/~dreibh/hipercontracer/
11 # ==========================================================================
12 #
13 # High-Performance Connectivity Tracer (HiPerConTracer)
14 # Copyright (C) 2015-2026 by Thomas Dreibholz
15 #
16 # This program is free software: you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation, either version 3 of the License, or
19 # (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #
29 # Contact: [email protected]
30
31
32 # ###### Bash completion for hipercontracer #################################
33 _hipercontracer()
34 {
35 # Based on: https://www.benningtons.net/index.php/bash-completion/
36 local cur prev words cword
37 if type -t _comp_initialize >/dev/null; then
38 _comp_initialize || return
39 elif type -t _init_completion >/dev/null; then
40 _init_completion || return
41 else
42 # Manual initialization for older bash completion versions:
43 COMPREPLY=()
44 # shellcheck disable=SC2034
45 cur="${COMP_WORDS[COMP_CWORD]}"
46 # shellcheck disable=SC2034
47 prev="${COMP_WORDS[COMP_CWORD-1]}"
48 # shellcheck disable=SC2034,SC2124
49 words="${COMP_WORDS[@]}"
50 # shellcheck disable=SC2034
51 cword="${COMP_CWORD}"
52 fi
53
54 case "${prev}" in
55 # ====== Generic value ===============================================
56 -L | --loglevel | \
57 -U | --userid | \
58 -# | --measurement-id | \
59 -D | --destination | \
60 --iterations | \
61 --tracerouteinterval | \
62 --tracerouteintervaldeviation | \
63 --tracerouteduration | \
64 --tracerouterounds | \
65 --tracerouteinitialmaxttl | \
66 --traceroutefinalmaxttl | \
67 --tracerouteincrementmaxttl | \
68 --traceroutepacketsize | \
69 --tracerouteudpsourceport | \
70 --tracerouteudpdestinationport | \
71 --pinginterval | \
72 --pingintervaldeviation | \
73 --pingexpiration | \
74 --pingburst | \
75 --pingttl | \
76 --pingpacketsize | \
77 --pingudpsourceport | \
78 --pingudpdestinationport | \
79 -x | --resultstransactionlength | \
80 -F | --resultsformat | \
81 -z | --resultstimestampdepth)
82 return
83 ;;
84 # ====== Special case: compression ====================================
85 -C | --resultscompression)
86 # shellcheck disable=SC2207
87 COMPREPLY=( $(compgen -W "none XZ BZip2 GZip" -- "${cur}") )
88 return
89 ;;
90 # ====== Special case: IO Module ======================================
91 -M | --iomodule)
92 # shellcheck disable=SC2207
93 COMPREPLY=( $(compgen -W "ICMP UDP" -- "${cur}") )
94 return
95 ;;
96 # ====== Special case: log file =======================================
97 -O | --logfile)
98 # Files with extension .log:
99 _filedir '@(log)'
100 return
101 ;;
102 # ====== Special case: source address =================================
103 -S | --source)
104 # Obtain addresses with default route by using "get-default-ips":
105 # shellcheck disable=SC2207
106 COMPREPLY=( $( compgen -W "$(get-default-ips)" -- "${cur}" ) )
107 return
108 ;;
109 # ====== Special case: on/off =========================================
110 -Z | --logcolor)
111 # shellcheck disable=SC2207
112 COMPREPLY=( $(compgen -W "on off" -- "${cur}") )
113 return
114 ;;
115 # ====== Special case: file ===========================================
116 --sources-from-file | \
117 --destinations-from-file)
118 # Arbitrary file names:
119 _filedir
120 return
121 ;;
122 # ====== Special case: directory ======================================
123 -R | --resultsdirectory)
124 # Arbitrary directories:
125 _filedir -d
126 return
127 ;;
128 esac
129
130 # ====== All options =====================================================
131 local opts="
132 -P
133 --ping
134 -T
135 --traceroute
136 -L
137 --loglevel
138 -Z
139 --logcolor
140 -O
141 --logfile
142 -q
143 --quiet
144 -v
145 --verbose
146 -U
147 --user
148 -#
149 --measurement-id
150 -S
151 --source
152 -D
153 --destination
154 --sources-from-file
155 --destinations-from-file
156 -M
157 --iomodule
158 -I
159 --iterations
160 --tracerouteinterval
161 --tracerouteintervaldeviation
162 --tracerouteduration
163 --tracerouterounds
164 --tracerouteinitialmaxttl
165 --traceroutefinalmaxttl
166 --tracerouteincrementmaxttl
167 --traceroutepacketsize
168 --tracerouteudpsourceport
169 --tracerouteudpdestinationport
170 --pinginterval
171 --pingintervaldeviation
172 --pingexpiration
173 --pingburst
174 --pingttl
175 --pingpacketsize
176 --pingudpsourceport
177 --pingudpdestinationport
178 -R
179 --resultsdirectory
180 -x
181 --resultstransactionlength
182 -C
183 --resultscompression
184 -F
185 --resultsformat
186 -z
187 --resultstimestampdepth
188 --check
189 -h
190 --help
191 --version
192 "
193 # shellcheck disable=SC2207
194 COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) )
195 return 0
196 }
197
198 complete -F _hipercontracer hipercontracer