|
| 1 | +[[ $OSTYPE == *@(freebsd|dragonflybsd|darwin|linux|solaris)* ]] || return 1 |
| 2 | + |
| 3 | +_comp_cmd_mfiutil() { |
| 4 | + local cur prev words cword comp_args |
| 5 | + _comp_initialize -- "$@" || return |
| 6 | + |
| 7 | + if [[ $cur == -* ]]; then |
| 8 | + # Complete global options |
| 9 | + local options="-u -d -e" |
| 10 | + case "$OSTYPE" in |
| 11 | + *freebsd*) |
| 12 | + options="$options -D -t" |
| 13 | + ;; |
| 14 | + *dragonflybsd*|*solaris*) |
| 15 | + options="$options -t" |
| 16 | + ;; |
| 17 | + esac |
| 18 | + local end_of_options= |
| 19 | + local w |
| 20 | + for w in "${words[@]:1:cword-1}"; do |
| 21 | + case "$w" in |
| 22 | + --) |
| 23 | + end_of_options=1 |
| 24 | + break |
| 25 | + ;; |
| 26 | + -*) |
| 27 | + ;; |
| 28 | + *) |
| 29 | + end_of_options=1 |
| 30 | + break |
| 31 | + ;; |
| 32 | + esac |
| 33 | + done |
| 34 | + if [[ ! $end_of_options ]]; then |
| 35 | + _comp_compgen -- -W '$options' |
| 36 | + return |
| 37 | + fi |
| 38 | + fi |
| 39 | + |
| 40 | + local REPLY |
| 41 | + _comp_count_args -a "-*[Dtu]" |
| 42 | + case $REPLY in |
| 43 | + 0) |
| 44 | + # Complete argument to global options |
| 45 | + case "$prev" in |
| 46 | + -D) |
| 47 | + _comp_compgen_filedir |
| 48 | + ;; |
| 49 | + -t) |
| 50 | + case "$OSTYPE" in |
| 51 | + *freebsd*|*dragonflybsd*) |
| 52 | + _comp_compgen -- -W 'mfi mrsas' |
| 53 | + ;; |
| 54 | + esac |
| 55 | + ;; |
| 56 | + esac |
| 57 | + ;; |
| 58 | + 1) |
| 59 | + _comp_compgen -- -W ' |
| 60 | + version show fail good rebuild syspd drive start abort locate |
| 61 | + cache name volume clear create delete add remove patrol stop |
| 62 | + foreign flash bbu ctrlprop' |
| 63 | + ;; |
| 64 | + 2) |
| 65 | + case "$prev" in |
| 66 | + show) |
| 67 | + _comp_compgen -- -W ' |
| 68 | + adapter battery config drives events firmware foreign |
| 69 | + logstate volumes patrol progress' |
| 70 | + ;; |
| 71 | + drive) |
| 72 | + _comp_compgen -- -W 'progress clear' |
| 73 | + ;; |
| 74 | + start) |
| 75 | + _comp_compgen -- -W 'rebuild patrol learn' |
| 76 | + ;; |
| 77 | + abort) |
| 78 | + _comp_compgen -- -W 'rebuild' |
| 79 | + ;; |
| 80 | + volume) |
| 81 | + _comp_compgen -- -W 'progress' |
| 82 | + ;; |
| 83 | + create) |
| 84 | + _comp_compgen -- -W ' |
| 85 | + jbod raid0 raid1 raid5 raid6 raid10 raid50 raid60 concat' |
| 86 | + ;; |
| 87 | + patrol) |
| 88 | + _comp_compgen -- -W 'disable auto manual' |
| 89 | + ;; |
| 90 | + stop) |
| 91 | + _comp_compgen -- -W 'patrol' |
| 92 | + ;; |
| 93 | + foreign) |
| 94 | + _comp_compgen -- -W 'scan clear diag preview import' |
| 95 | + ;; |
| 96 | + flash) |
| 97 | + _comp_compgen_filedir |
| 98 | + ;; |
| 99 | + bbu) |
| 100 | + _comp_compgen -- -W 'learn-delay autolearn-mode bbu-mode' |
| 101 | + ;; |
| 102 | + ctrlprop) |
| 103 | + _comp_compgen -- -W 'rebuild alarm' |
| 104 | + ;; |
| 105 | + esac |
| 106 | + ;; |
| 107 | + 3) |
| 108 | + case "${words[cword-2]}.$prev" in |
| 109 | + locate.*) |
| 110 | + _comp_compgen -- -W 'on off' |
| 111 | + ;; |
| 112 | + cache.*) |
| 113 | + _comp_compgen -- -W ' |
| 114 | + enable disable reads writes write-back write-through |
| 115 | + read-ahead bad-bbu-write-cache write-cache' |
| 116 | + ;; |
| 117 | + ctrlprop.alarm) |
| 118 | + _comp_compgen -- -W 'on off 1 0' |
| 119 | + ;; |
| 120 | + esac |
| 121 | + ;; |
| 122 | + esac |
| 123 | +} |
| 124 | +complete -F _comp_cmd_mfiutil mfiutil mrsasutil |
0 commit comments