| 1 |
_wdctl_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
case $prev in |
| 8 |
'-f'|'--flags') |
| 9 |
local FLAGS |
| 10 |
FLAGS="ALARMONLY |
| 11 |
CARDRESET |
| 12 |
EXTERN1 |
| 13 |
EXTERN2 |
| 14 |
FANFAULT |
| 15 |
KEEPALIVEPING |
| 16 |
MAGICCLOSE |
| 17 |
OVERHEAT |
| 18 |
POWEROVER |
| 19 |
POWERUNDER |
| 20 |
PRETIMEOUT |
| 21 |
SETTIMEOUT" |
| 22 |
COMPREPLY=( $(compgen -W "$FLAGS" -- $cur) ) |
| 23 |
return 0 |
| 24 |
;; |
| 25 |
'-o'|'--output') |
| 26 |
local prefix realcur OUTPUT_ALL OUTPUT |
| 27 |
realcur="${cur##*,}" |
| 28 |
prefix="${cur%$realcur}" |
| 29 |
OUTPUT_ALL="FLAG DESCRIPTION STATUS BOOT-STATUS DEVICE" |
| 30 |
for WORD in $OUTPUT_ALL; do |
| 31 |
if ! [[ $prefix == *"$WORD"* ]]; then |
| 32 |
OUTPUT="$WORD ${OUTPUT:-""}" |
| 33 |
fi |
| 34 |
done |
| 35 |
compopt -o nospace |
| 36 |
COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) ) |
| 37 |
return 0 |
| 38 |
;; |
| 39 |
'-s'|'--settimeout') |
| 40 |
COMPREPLY=( $(compgen -W "seconds" -- $cur) ) |
| 41 |
return 0 |
| 42 |
;; |
| 43 |
'-h'|'--help'|'-V'|'--version') |
| 44 |
return 0 |
| 45 |
;; |
| 46 |
esac |
| 47 |
case $cur in |
| 48 |
-*) |
| 49 |
OPTS="--flags |
| 50 |
--noflags |
| 51 |
--noident |
| 52 |
--noheadings |
| 53 |
--oneline |
| 54 |
--output |
| 55 |
--raw |
| 56 |
--notimeouts |
| 57 |
--settimeout |
| 58 |
--flags-only |
| 59 |
--setpregovernor |
| 60 |
--setpretimeout |
| 61 |
--help |
| 62 |
--version" |
| 63 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 64 |
return 0 |
| 65 |
;; |
| 66 |
esac |
| 67 |
local IFS=$'\n' |
| 68 |
compopt -o filenames |
| 69 |
COMPREPLY=( $(compgen -f -- ${cur:-"/dev/"}) ) |
| 70 |
return 0 |
| 71 |
} |
| 72 |
complete -F _wdctl_module wdctl |