Debian Codegraph @

src/hpct-query.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 hpct-query #####################################
33 _hpct_query()
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 # ====== Database configuration file =====================================
55 if [ "${cword}" -eq 1 ] ; then
56 _filedir '@(conf)'
57 return
58
59 # ====== Measurement type ================================================
60 elif [ "${cword}" -eq 2 ] ; then
61 # shellcheck disable=SC2207
62 COMPREPLY=( $(compgen -W "ping traceroute" -- "${cur}") )
63 return
64
65 # ====== Options =========================================================
66 else
67 case "${prev}" in
68 # ====== Generic value ============================================
69 -L | --loglevel | \
70 -T | --table | \
71 -V | --table-version | \
72 --from-time | \
73 --to-time | \
74 --from-measurement-id | \
75 --to-measurement-id)
76 return
77 ;;
78 # ====== Special case: file ========================================
79 -o | --output)
80 # HiPerConTracer results file names:
81 _filedir '@(hpct\.xz|hpct\.bz2|hpct\.gz|hpct|results\.xz|results\.bz2|results\.gz|results)'
82 return
83 ;;
84 # ====== Special case: file ========================================
85 -M | --address-to-measurementid)
86 # Arbitrary file names:
87 _filedir
88 return
89 ;;
90 # ====== Special case: log file ====================================
91 -O | --logfile)
92 # Files with extension .log:
93 _filedir '@(log)'
94 return
95 ;;
96 # ====== Special case: on/off ======================================
97 -Z | --logcolor)
98 # shellcheck disable=SC2207
99 COMPREPLY=( $(compgen -W "on off" -- "${cur}") )
100 return
101 ;;
102 esac
103 fi
104
105 # ====== All options =====================================================
106 local opts="
107 -L
108 --loglevel
109 -Z
110 --logcolor
111 -O
112 --logfile
113 -q
114 --quiet
115 -v
116 --verbose
117 -o
118 --output
119 -T
120 --table
121 -V
122 --table-version
123 -M
124 --address-to-measurementid
125 --deduplication
126 --from-time
127 --to-time
128 --from-measurement-id
129 --to-measurement-id
130 -h
131 --help
132 --version
133 "
134 # shellcheck disable=SC2207
135 COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) )
136 return 0
137 }
138
139 complete -F _hpct_query hpct-query