Use _split_longopt.

This commit is contained in:
Ville Skyttä 2009-04-18 13:15:07 +03:00
parent 97e40f4e0c
commit 4073edd2af

View File

@ -56,136 +56,74 @@ _smartctl_test()
_smartctl() _smartctl()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
# --name value style option _split_longopt && split=true
case "$prev" in case "$prev" in
-q) -q|--quietmode)
_smartctl_quietmode _smartctl_quietmode
;; ;;
-d) -d|--device)
_smartctl_device _smartctl_device
return 0 return 0
;; ;;
-t) -t|--tolerance)
_smartctl_tolerance _smartctl_tolerance
return 0 return 0
;; ;;
-b) -b|--badsum)
_smartctl_badsum _smartctl_badsum
return 0 return 0
;; ;;
-r) -r|--report)
_smartctl_report _smartctl_report
return 0 return 0
;; ;;
-s) -n|--nocheck)
_smartctl_powermode
return 0
;;
-s|--smart|-o|--offlineauto|-S|--saveauto)
_smartctl_feature _smartctl_feature
return 0 return 0
;; ;;
-o) -l|--log)
_smartctl_feature
return 0
;;
-S)
_smartctl_feature
return 0
;;
-l)
_smartctl_log _smartctl_log
return 0 return 0
;; ;;
-v) -v|--vendorattribute)
_smartctl_vendorattribute _smartctl_vendorattribute
return 0 return 0
;; ;;
-F) -F|--firmwarebug)
_smartctl_firmwarebug _smartctl_firmwarebug
return 0 return 0
;; ;;
-P) -P|--presets)
_smartctl_presets _smartctl_presets
return 0 return 0
;; ;;
-t) -t|--test)
_smartctl_test _smartctl_test
return 0 return 0
;; ;;
esac esac
# --name=value style option $split && return 0
if [[ "$cur" == *=* ]]; then
prev=${cur/=*/}
cur=${cur/*=/}
case "$prev" in
--quietmode)
_smartctl_quietmode
return 0
;;
--device)
_smartctl_device
return 0
;;
--tolerance)
_smartctl_tolerance
return 0
;;
--badsum)
_smartctl_badsum
return 0
;;
--report)
_smartctl_report
return 0
;;
--smart)
_smartctl_feature
return 0
;;
--offlineauto)
_smartctl_feature
return 0
;;
--saveauto)
_smartctl_feature
return 0
;;
--log)
_smartctl_log
return 0
;;
--vendorattribute)
_smartctl_vendorattribute
return 0
;;
--firmwarebug)
_smartctl_firmwarebug
return 0
;;
--presets)
_smartctl_presets
return 0
;;
--test)
_smartctl_test
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h --help --usage -V --version \ COMPREPLY=( $( compgen -W '-h --help --usage -V --version \
--copyright --license-i --info -a --all -q \ --copyright --license-i --info -a --all -q \
--quietmode= -d --device= -T --tolerance= -b --badsum= \ --quietmode -d --device -T --tolerance -b --badsum \
-r --report= -s --smart= -o --offlineauto= -S \ -r --report -s --smart -o --offlineauto -S \
--saveauto= -H --health -c --capabilities -A \ --saveauto -H --health -c --capabilities -A \
--attributes -l --log= -v --vendorattribute= -F \ --attributes -l --log -v --vendorattribute -F \
--firmwarebug= -P --presets= -t --test= -C \ --firmwarebug -P --presets -t --test -C \
--captive -X --abort' -- $cur ) ) --captive -X --abort' -- $cur ) )
else else
cur=${cur:=/dev/} cur=${cur:=/dev/}