1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
# (C) 2010 magicant
# Completion script for the "array" built-in command.
function completion/array {
typeset OPTIONS ARGOPT PREFIX
OPTIONS=( #>#
"d --delete; remove elements from an array"
"i --insert; insert elements to an array"
"s --set; replace an element of an array"
"--help"
) #<#
command -f completion//parseoptions -es
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(*)
typeset i=1 type=
while [ $i -le ${WORDS[#]} ]; do
case ${WORDS[i++]} in
(-d|--delete) type=d ;;
(-i|--insert) type=i ;;
(-s|--set ) type=s ;;
(--) break ;;
esac
done
if [ $i -gt ${WORDS[#]} ]; then
complete --array
else
case $type in
(d)
;; # TODO: complete array index
(i|s)
if [ $i -eq ${WORDS[#]} ]; then
# TODO: complete array index
else
complete -f
fi
;;
(*)
complete -f
;;
esac
fi
;;
esac
}
# vim: set ft=sh ts=8 sts=8 sw=8 noet:
|