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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
# gnokii(1) completion -*- shell-script -*-
_gnokii_memory_type()
{
# TODO: reduce the number of choices
COMPREPLY=($(compgen -W "IN OU SM ME MT" -- "$cur"))
}
_gnokii()
{
local cur prev words cword pprev tprev fprev
_init_completion || return
case $prev in
--config)
_filedir
return
;;
--phone)
local config_file
for config_file in "$XDG_CONFIG_HOME/gnokii/config" \
"$HOME/.config/gnokii/config" "$HOME/.gnokiirc" \
"$XDG_CONFIG_DIRS/gnokii/config" /etc/gnokiirc; do
[[ -f $config_file ]] && break
done
[[ ! -f $config_file ]] && return
COMPREPLY=($(compgen -W \
"$(command sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file)" \
-- "$cur"))
return
;;
--help)
COMPREPLY=($(compgen -W 'all monitor sms mms phonebook calendar
todo dial profile settings wap logo ringtone security file
other' -- "$cur"))
return
;;
--version | --shell | ping)
return
;;
# MONITOR
--monitor)
COMPREPLY=($(compgen -W 'delay once' -- "$cur"))
return
;;
--getdisplaystatus | --displayoutput)
return
;;
--netmonitor)
COMPREPLY=($(compgen -W 'reset off field devel next nr' \
-- "$cur"))
return
;;
# SMS
--sendsms)
# (how)TODO ?
return
;;
--savesms)
COMPREPLY=($(compgen -W '--sender --smsc --smscno --folder
--location --sent --read --deliver --datetime' -- "$cur"))
return
;;
--memory-type | --memory | --getsms | --deletesms | --getmms | --deletemms | \
--getphonebook | --deletephonebook)
_gnokii_memory_type
return
;;
--getsmsc | --getcalendarnote | --deletecalendarnote | --gettodo | \
--getspeeddial)
# TODO: grab a specific entry ID
return
;;
--setsmsc | --smsreader | --createsmsfolder | --deletealltodos | \
--showsmsfolderstatus)
return
;;
--deletesmsfolder | --folder)
# TODO: folderid
return
;;
--writephonebook)
COMPREPLY=($(compgen -W '--overwrite --find-free --memory-type
--location --vcard --ldif' -- "$cur"))
return
;;
--writecalendarnote | --writetodo)
_filedir vcf
return
;;
# DIAL
--setspeeddial | --dialvoice | --senddtmf | --answercall | --hangup)
# TODO
return
;;
--divert)
COMPREPLY=($(compgen -W '--op' -- "$cur"))
return
;;
# PROFILE
--getprofile | --setactiveprofile)
# TODO
return
;;
--setprofile | --getactiveprofile)
return
;;
# SETTINGS
--reset)
COMPREPLY=($(compgen -W 'soft hard' -- "$cur"))
return
;;
--setdatetime | --setalarm)
# TODO
return
;;
--getdatetime | --getalarm)
return
;;
# WAP
--getwapbookmark | --writewapbookmark | --deletewapbookmark | \
--getwapsetting | --writewapsetting | --activatewapsetting)
return
;;
# LOGOS
--sendlogo)
COMPREPLY=($(compgen -W 'caller op picture' -- "$cur"))
return
;;
--setlogo | --getlogo)
COMPREPLY=($(compgen -W 'op startup caller dealer text' \
-- "$cur"))
return
;;
--viewlogo)
# TODO: logofile
return
;;
--entersecuritycode)
COMPREPLY=($(compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur"))
return
;;
# TODO: RINGTONES
esac
# second level completion
if [[ $((cword - 2)) -ge 1 && ${words[cword - 2]} =~ --* ]]; then
pprev=${words[cword - 2]}
case $pprev in
--setspeeddial)
_gnokii_memory_type
return
;;
--getsms | --deletesms | --getmms | --deletemms | --getphonebook | \
--writetodo | --writecalendarnote)
# TODO: start number
return
;;
--gettodo | --getcalendarnote)
COMPREPLY=($(compgen -W '{1..9} end --vCal' -- "$cur"))
return
;;
--deletecalendarnote)
COMPREPLY=($(compgen -W '{1..9} end' -- "$cur"))
return
;;
--divert)
COMPREPLY=($(compgen -W 'register enable query disable
erasure' -- "$cur"))
return
;;
esac
fi
# third level completion
if [[ $((cword - 3)) -ge 1 && ${words[cword - 3]} =~ --* ]]; then
tprev=${words[cword - 3]}
case $tprev in
--deletesms | --deletemms)
COMPREPLY=($(compgen -W 'end' -- "$cur"))
return
;;
--getphonebook | --writetodo | --writecalendarnote)
COMPREPLY=($(compgen -W '{1..9} end' -- "$cur"))
return
;;
--gettodo | --getcalendarnote)
[[ ${words[cword - 1]} == end ]] &&
COMPREPLY=($(compgen -W '--vCal' -- "$cur"))
return
;;
--divert)
COMPREPLY=($(compgen -W '--type' -- "$cur"))
return
;;
esac
fi
# fourth level completion
if [[ $((cword - 4)) -ge 1 && ${words[cword - 4]} =~ --* ]]; then
fprev=${words[cword - 4]}
case $fprev in
--getphonebook)
COMPREPLY=($(compgen -W '--raw --vcard --ldif' -- "$cur"))
return
;;
--divert)
COMPREPLY=($(compgen -W 'all busy noans outofreach notavail' \
-- "$cur"))
return
;;
esac
fi
# safer to use LANG=C
local all_cmd="$(LANG=C _parse_help $1 "--help all")"
# these 2 below are allowed in combination with others
local main_cmd=$(command grep -v -- '--config\|--phone' <<<"$all_cmd")
# don't provide main command completions if one is
# already on the command line
[[ $COMP_LINE =~ $(tr ' ' '\b|' <<<$main_cmd) ]] && return
COMPREPLY=($(compgen -W "$all_cmd" -- "$cur"))
} &&
complete -F _gnokii gnokii
# ex: filetype=sh
|