PageRenderTime 6ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/bash_completion_lib/complete/smartctl

http://github.com/brinkman83/bashrc
#! | 194 lines | 182 code | 12 blank | 0 comment | 0 complexity | c46e614f836e18deac6f0756c06a51ae MD5 | raw file
  1# smartctl(8) completion
  2
  3
  4comp_include _filedir _get_cword
  5
  6
  7_smartctl_quietmode()
  8{
  9    COMPREPLY=( $( compgen -W 'errorsonly silent' -- $cur ) )
 10}
 11_smartctl_device()
 12{
 13    COMPREPLY=( $( compgen -W 'ata scsi 3ware' -- $cur ) )
 14}
 15_smartctl_tolerance()
 16{
 17    COMPREPLY=( $( compgen -W 'warn exit ignore' -- $cur ) )
 18}
 19_smartctl_badsum()
 20{
 21    COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) )
 22}
 23_smartctl_report()
 24{
 25    COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) )
 26}
 27_smartctl_feature()
 28{
 29    COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
 30}
 31_smartctl_log()
 32{
 33    COMPREPLY=( $( compgen -W 'error selftest selective directory' -- $cur ) )
 34}
 35_smartctl_vendorattribute()
 36{
 37    COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \
 38        9,temp 192,emergencyretractcyclect 193,loadunload \
 39        194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
 40        200,writeerrorcount 201,detectedtacount 220,temp' -- $cur ) )
 41}
 42_smartctl_firmwarebug()
 43{
 44    COMPREPLY=( $( compgen -W 'none samsung samsung2' -- $cur ) )
 45}
 46_smartctl_presets()
 47{
 48    COMPREPLY=( $( compgen -W 'use ignore show showall' -- $cur ) )
 49}
 50_smartctl_test()
 51{
 52    COMPREPLY=( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) )
 53}
 54
 55_smartctl()
 56{
 57    local cur prev
 58
 59    COMPREPLY=()
 60    cur=`_get_cword`
 61    prev=${COMP_WORDS[COMP_CWORD-1]}
 62
 63    # --name value style option
 64    case "$prev" in
 65        -q)
 66            _smartctl_quietmode
 67            ;;
 68        -d)
 69            _smartctl_device
 70            return 0
 71            ;;
 72        -t)
 73            _smartctl_tolerance
 74            return 0
 75            ;;
 76        -b)
 77            _smartctl_badsum
 78            return 0
 79            ;;
 80        -r)
 81            _smartctl_report
 82            return 0
 83            ;;
 84        -s)
 85            _smartctl_feature
 86            return 0
 87            ;;
 88        -o)
 89            _smartctl_feature
 90            return 0
 91            ;;
 92        -S)
 93            _smartctl_feature
 94            return 0
 95            ;;
 96        -l)
 97            _smartctl_log
 98            return 0
 99            ;;
100        -v)
101            _smartctl_vendorattribute
102            return 0
103            ;;
104        -F)
105            _smartctl_firmwarebug
106            return 0
107            ;;
108        -P)
109            _smartctl_presets
110            return 0
111            ;;
112        -t)
113            _smartctl_test
114            return 0
115            ;;
116    esac
117
118    # --name=value style option
119    if [[ "$cur" == *=* ]]; then
120        prev=${cur/=*/}
121        cur=${cur/*=/}
122        case "$prev" in
123            --quietmode)
124                _smartctl_quietmode
125                return 0
126                ;;
127            --device)
128                _smartctl_device
129                return 0
130                ;;
131            --tolerance)
132                _smartctl_tolerance
133                return 0
134                ;;
135            --badsum)
136                _smartctl_badsum
137                return 0
138                ;;
139            --report)
140                _smartctl_report
141                return 0
142                ;;
143            --smart)
144                _smartctl_feature
145                return 0
146                ;;
147            --offlineauto)
148                _smartctl_feature
149                return 0
150                ;;
151            --saveauto)
152                _smartctl_feature
153                return 0
154                ;;
155            --log)
156                _smartctl_log
157                return 0
158                ;;
159            --vendorattribute)
160                _smartctl_vendorattribute
161                return 0
162                ;;
163            --firmwarebug)
164                _smartctl_firmwarebug
165                return 0
166                ;;
167            --presets)
168                _smartctl_presets
169                return 0
170                ;;
171            --test)
172                _smartctl_test
173                return 0
174                ;;
175        esac
176    fi
177
178
179    if [[ "$cur" == -* ]]; then
180        COMPREPLY=( $( compgen -W '-h --help --usage -V --version \
181            --copyright --license-i --info -a --all -q \
182            --quietmode= -d --device= -T --tolerance= -b --badsum= \
183            -r --report= -s --smart= -o --offlineauto= -S \
184            --saveauto= -H --health -c --capabilities -A \
185            --attributes -l --log= -v --vendorattribute= -F \
186            --firmwarebug= -P --presets= -t --test= -C \
187            --captive -X --abort' -- $cur ) )
188    else
189        cur=${cur:=/dev/}
190        _filedir
191    fi
192} # _smartctl()
193
194