| 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-importer ################################## |
| 33 |
_hpct_importer() |
| 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 |
-X | --import-mode | \ |
| 58 |
-Y | --import-max-depth | \ |
| 59 |
--import-file-path-filter | \ |
| 60 |
--ping-workers | \ |
| 61 |
--ping-files | \ |
| 62 |
--traceroute-workers | \ |
| 63 |
--traceroute-files) |
| 64 |
return |
| 65 |
;; |
| 66 |
# ====== Special case: directory ====================================== |
| 67 |
-I | --import-file-path | \ |
| 68 |
--bad-file-path | -G | \ |
| 69 |
--good-file-path | -F) |
| 70 |
# Arbitrary directories: |
| 71 |
_filedir -d |
| 72 |
return |
| 73 |
;; |
| 74 |
# ====== Special case: configuration file ============================= |
| 75 |
-C | --importer-config | \ |
| 76 |
-D | --database-config) |
| 77 |
# Files with extension .conf: |
| 78 |
_filedir '@(conf)' |
| 79 |
return |
| 80 |
;; |
| 81 |
# ====== Special case: log file ======================================= |
| 82 |
-O | --logfile) |
| 83 |
# Files with extension .log: |
| 84 |
_filedir '@(log)' |
| 85 |
return |
| 86 |
;; |
| 87 |
# ====== Special case: on/off ========================================= |
| 88 |
-Z | --logcolor) |
| 89 |
# shellcheck disable=SC2207 |
| 90 |
COMPREPLY=( $(compgen -W "on off" -- "${cur}") ) |
| 91 |
return |
| 92 |
;; |
| 93 |
esac |
| 94 |
|
| 95 |
# ====== All options ===================================================== |
| 96 |
local opts=" |
| 97 |
-C |
| 98 |
--importer-config |
| 99 |
-D |
| 100 |
--database-config |
| 101 |
-L |
| 102 |
--loglevel |
| 103 |
-Z |
| 104 |
--logcolor |
| 105 |
-O |
| 106 |
--logfile |
| 107 |
-q |
| 108 |
--quiet |
| 109 |
-v |
| 110 |
--verbose |
| 111 |
-X |
| 112 |
--import-mode |
| 113 |
-Y |
| 114 |
--import-max-depth |
| 115 |
-I |
| 116 |
--import-file-path |
| 117 |
-B |
| 118 |
--bad-file-path |
| 119 |
-G |
| 120 |
--good-file-path |
| 121 |
-F |
| 122 |
--import-file-path-filter |
| 123 |
-Q |
| 124 |
--quit-when-idle |
| 125 |
--ping-workers |
| 126 |
--ping-files |
| 127 |
--traceroute-workers |
| 128 |
--traceroute-files |
| 129 |
-h |
| 130 |
--help |
| 131 |
--version |
| 132 |
" |
| 133 |
# shellcheck disable=SC2207 |
| 134 |
COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) ) |
| 135 |
return 0 |
| 136 |
} |
| 137 |
|
| 138 |
complete -F _hpct_importer hpct-importer |