| 1 |
_irqtop_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 |
'-b'|'--batch') |
| 9 |
return 0 |
| 10 |
;; |
| 11 |
'-c'|'--cpu-stat') |
| 12 |
COMPREPLY=( $(compgen -W "auto enable disable always never" -- $cur) ) |
| 13 |
return 0 |
| 14 |
;; |
| 15 |
'-C'|'--cpu-list') |
| 16 |
return 0 |
| 17 |
;; |
| 18 |
'-t'|'--threshold') |
| 19 |
return 0 |
| 20 |
;; |
| 21 |
'-d'|'--delay') |
| 22 |
COMPREPLY=( $(compgen -W "secs" -- $cur) ) |
| 23 |
return 0 |
| 24 |
;; |
| 25 |
'-n'|'--iter') |
| 26 |
COMPREPLY=( $(compgen -W "the max iterations" -- $cur) ) |
| 27 |
return 0 |
| 28 |
;; |
| 29 |
'-s'|'--sort') |
| 30 |
COMPREPLY=( $(compgen -W "irq total delta name" -- $cur) ) |
| 31 |
return 0 |
| 32 |
;; |
| 33 |
'-o'|'--output') |
| 34 |
local prefix realcur OUTPUT |
| 35 |
realcur="${cur##*,}" |
| 36 |
prefix="${cur%$realcur}" |
| 37 |
for WORD in "IRQ TOTAL DELTA NAME"; do |
| 38 |
if ! [[ $prefix == *"$WORD"* ]]; then |
| 39 |
OUTPUT="$WORD ${OUTPUT:-""}" |
| 40 |
fi |
| 41 |
done |
| 42 |
compopt -o nospace |
| 43 |
COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) ) |
| 44 |
return 0 |
| 45 |
;; |
| 46 |
'-h'|'--help'|'-V'|'--version') |
| 47 |
return 0 |
| 48 |
;; |
| 49 |
esac |
| 50 |
OPTS=" --batch |
| 51 |
--json |
| 52 |
--cpu-stat |
| 53 |
--cpu-list |
| 54 |
--delay |
| 55 |
--iter |
| 56 |
--sort |
| 57 |
--output |
| 58 |
--softirq |
| 59 |
--threshold |
| 60 |
--help |
| 61 |
--version" |
| 62 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 63 |
return 0 |
| 64 |
} |
| 65 |
complete -F _irqtop_module irqtop |