gnokii: Various minor and cosmetic fixes

This commit is contained in:
Ville Skyttä 2015-05-11 12:13:41 +03:00
parent 3eb1b0dda8
commit b07e355111

View File

@ -1,232 +1,238 @@
# gnokii(1) completion # gnokii(1) completion -*- shell-script -*-
_gnokii_memory_type() { _gnokii_memory_type()
{
# TODO: reduce the number of choices # TODO: reduce the number of choices
COMPREPLY=( $( compgen -W "IN OU SM ME MT" -- "$cur" ) ) COMPREPLY=( $( compgen -W "IN OU SM ME MT" -- "$cur" ) )
} }
_gnokii_folder_ids() { _gnokii_folder_ids()
{
gnokii --showsmsfolderstatus gnokii --showsmsfolderstatus
} }
_gnokii() { _gnokii()
{
local cur prev words cword pprev tprev fprev local cur prev words cword pprev tprev fprev
_init_completion || return _init_completion || return
case $prev in case $prev in
--config) --config)
_filedir _filedir
return 0 return
;; ;;
--phone) --phone)
local config_file="$XDG_CONFIG_HOME/gnokii/config" local config_file
[[ ! -f $config_file ]] && config_file="$HOME/.config/gnokii/config" for config_file in "$XDG_CONFIG_HOME/gnokii/config" \
[[ ! -f $config_file ]] && config_file="$HOME/.gnokiirc" "$HOME/.config/gnokii/config" "$HOME/.gnokiirc" \
[[ ! -f $config_file ]] && config_file="$XDG_CONFIG_DIRS/gnokii/config" "$XDG_CONFIG_DIRS/gnokii/config" /etc/gnokiirc ; do
[[ ! -f $config_file ]] && config_file=/etc/gnokiirc [[ -f $config_file ]] && break
[[ ! -f $config_file ]] && return 0 done
COMPREPLY=( $( compgen -W "$(sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file)" \ [[ ! -f $config_file ]] && return
COMPREPLY=( $( compgen -W \
"$( sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file )" \
-- "$cur" ) ) -- "$cur" ) )
return 0 return
;; ;;
--help) --help)
COMPREPLY=( $( compgen -W 'all monitor sms mms phonebook calendar todo \ COMPREPLY=( $( compgen -W 'all monitor sms mms phonebook calendar
dial profile settings wap logo ringtone security \ todo dial profile settings wap logo ringtone security file
file other' -- "$cur" ) ) other' -- "$cur" ) )
return 0 return
;; ;;
# no argument
--version|--shell|ping) --version|--shell|ping)
return 0 return
;; ;;
# MONITOR # MONITOR
--monitor) --monitor)
COMPREPLY=( $( compgen -W 'delay once' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'delay once' -- "$cur" ) )
return 0 return
;; ;;
# no argument
--getdisplaystatus|--displayoutput) --getdisplaystatus|--displayoutput)
return 0 return
;; ;;
--netmonitor) --netmonitor)
COMPREPLY=( $( compgen -W 'reset off field devel next nr' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'reset off field devel next nr' \
return 0 -- "$cur" ) )
return
;; ;;
# SMS # SMS
--sendsms) --sendsms)
# (how)TODO ? # (how)TODO ?
return 0 return
;; ;;
--savesms) --savesms)
COMPREPLY=( $( compgen -W '--sender --smsc --smscno --folder --location \ COMPREPLY=( $( compgen -W '--sender --smsc --smscno --folder
--sent --read --deliver --datetime' -- $cur ) ) --location --sent --read --deliver --datetime' -- "$cur" ) )
return 0 return
;; ;;
--memory-type|--memory|--getsms|--deletesms|--getmms|--deletemms| \ --memory-type|--memory|--getsms|--deletesms|--getmms|--deletemms|\
--getphonebook|--deletephonebook) --getphonebook|--deletephonebook)
_gnokii_memory_type _gnokii_memory_type
return 0 return
;; ;;
--getsmsc|--getcalendarnote|--deletecalendarnote|--gettodo|--getspeeddial) --getsmsc|--getcalendarnote|--deletecalendarnote|--gettodo|\
--getspeeddial)
# TODO: grab a specific entry ID # TODO: grab a specific entry ID
return 0 return
;; ;;
# no argument --setsmsc|--smsreader|--createsmsfolder|--deletealltodos|\
--setsmsc|--smsreader|--createsmsfolder|--deletealltodos|--showsmsfolderstatus) --showsmsfolderstatus)
return 0 return
;; ;;
--deletesmsfolder|--folder) --deletesmsfolder|--folder)
# TODO: folderid # TODO: folderid
return 0 return
;; ;;
--writephonebook) --writephonebook)
COMPREPLY=( $( compgen -W '--overwrite --find-free --memory-type \ COMPREPLY=( $( compgen -W '--overwrite --find-free --memory-type
--location --vcard --ldif' -- $cur ) ) --location --vcard --ldif' -- "$cur" ) )
return 0 return
;; ;;
--writecalendarnote|--writetodo) --writecalendarnote|--writetodo)
_filedir vcf _filedir vcf
return 0 return
;; ;;
# DIAL # DIAL
--setspeeddial|--dialvoice|--senddtmf|--answercall|--hangup) --setspeeddial|--dialvoice|--senddtmf|--answercall|--hangup)
# TODO # TODO
return 0 return
;; ;;
--divert) --divert)
COMPREPLY=( $( compgen -W '--op' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--op' -- "$cur" ) )
return 0 return
;; ;;
# PROFILE # PROFILE
--getprofile|--setactiveprofile) --getprofile|--setactiveprofile)
# TODO # TODO
return 0 return
;; ;;
--setprofile|--getactiveprofile) --setprofile|--getactiveprofile)
return 0 return
;; ;;
# SETTINGS # SETTINGS
--reset) --reset)
COMPREPLY=( $( compgen -W 'soft hard' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'soft hard' -- "$cur" ) )
return 0 return
;; ;;
--setdatetime|--setalarm) --setdatetime|--setalarm)
# TODO # TODO
return 0 return
;; ;;
--getdatetime|--getalarm) --getdatetime|--getalarm)
return 0 return
;; ;;
# WAP # WAP
--getwapbookmark|--writewapbookmark|--deletewapbookmark|--getwapsetting| \ --getwapbookmark|--writewapbookmark|--deletewapbookmark|\
--writewapsetting|--activatewapsetting) --getwapsetting|--writewapsetting|--activatewapsetting)
return 0 return
;; ;;
# LOGOS # LOGOS
--sendlogo) --sendlogo)
COMPREPLY=( $( compgen -W 'caller op picture' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'caller op picture' -- "$cur" ) )
return 0 return
;; ;;
--setlogo|--getlogo) --setlogo|--getlogo)
COMPREPLY=( $( compgen -W 'op startup caller dealer text' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'op startup caller dealer text' \
return 0 -- "$cur" ) )
return
;; ;;
--viewlogo) --viewlogo)
# TODO: logofile # TODO: logofile
return 0 return
;; ;;
--entersecuritycode) --entersecuritycode)
COMPREPLY=( $( compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur" ) )
return 0 return
;; ;;
# TODO: RINGTONES # TODO: RINGTONES
esac esac
# second level completion # second level completion
if [[ $((cword-2)) -ge 1 && ${words[$((cword-2))]} =~ --* ]]; then if [[ $((cword-2)) -ge 1 && ${words[cword-2]} =~ --* ]]; then
pprev=${words[$((cword-2))]} pprev=${words[cword-2]}
case $pprev in case $pprev in
--setspeeddial) --setspeeddial)
_gnokii_memory_type _gnokii_memory_type
return 0 return
;; ;;
--getsms|--deletesms|--getmms|--deletemms|--getphonebook|--writetodo| \ --getsms|--deletesms|--getmms|--deletemms|--getphonebook|\
--writecalendarnote) --writetodo|--writecalendarnote)
# TODO: start number # TODO: start number
return 0 return
;; ;;
--gettodo|--getcalendarnote) --gettodo|--getcalendarnote)
COMPREPLY=( $( compgen -W '{1..9} end --vCal' -- "$cur" ) ) COMPREPLY=( $( compgen -W '{1..9} end --vCal' -- "$cur" ) )
return 0 return
;; ;;
--deletecalendarnote) --deletecalendarnote)
COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) ) COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) )
return 0 return
;; ;;
--divert) --divert)
COMPREPLY=( $( compgen -W 'register enable query disable erasure' \ COMPREPLY=( $( compgen -W 'register enable query disable
-- "$cur" ) ) erasure' -- "$cur" ) )
return 0 return
;; ;;
esac esac
fi fi
# third level completion # third level completion
if [[ $((cword-3)) -ge 1 && ${words[$((cword-3))]} =~ --* ]]; then if [[ $((cword-3)) -ge 1 && ${words[cword-3]} =~ --* ]]; then
tprev=${words[$((cword-3))]} tprev=${words[cword-3]}
case $tprev in case $tprev in
--deletesms|--deletemms) --deletesms|--deletemms)
COMPREPLY=( $( compgen -W 'end' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'end' -- "$cur" ) )
return 0 return
;; ;;
--getphonebook|--writetodo|--writecalendarnote) --getphonebook|--writetodo|--writecalendarnote)
COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) ) COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) )
return 0 return
;; ;;
--gettodo|--getcalendarnote) --gettodo|--getcalendarnote)
[[ ${words[$((cword-1))]} = end ]] && \ [[ ${words[cword-1]} == end ]] && \
COMPREPLY=( $( compgen -W '--vCal' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--vCal' -- "$cur" ) )
return 0 return
;; ;;
--divert) --divert)
COMPREPLY=( $( compgen -W '--type' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--type' -- "$cur" ) )
return 0 return
esac esac
fi fi
# fourth level completion # fourth level completion
if [[ $((cword-4)) -ge 1 && ${words[$((cword-4))]} =~ --* ]]; then if [[ $((cword-4)) -ge 1 && ${words[cword-4]} =~ --* ]]; then
fprev=${words[$((cword-4))]} fprev=${words[cword-4]}
case $fprev in case $fprev in
--getphonebook) --getphonebook)
COMPREPLY=( $( compgen -W '--raw --vcard --ldif' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--raw --vcard --ldif' -- "$cur" ) )
return 0 return
;; ;;
--divert) --divert)
COMPREPLY=( $( compgen -W 'all busy noans outofreach notavail' \ COMPREPLY=( $( compgen -W 'all busy noans outofreach notavail' \
-- "$cur" ) ) -- "$cur" ) )
return 0 return
esac esac
fi fi
# safer to use LANG=C # safer to use LANG=C
local all_cmd="$(LANG=C _parse_help $1 "--help all")" local all_cmd="$( LANG=C _parse_help $1 "--help all" )"
# these 2 below are allowed in combination with others # these 2 below are allowed in combination with others
local main_cmd=$(echo "$a"|grep -v -- '--config\|--phone') local main_cmd=$( echo "$all_cmd" | grep -v -- '--config\|--phone' )
# don't provide main command completions if one is # don't provide main command completions if one is
# already on the command line # already on the command line
[[ $COMP_LINE =~ $(tr ' ' '|'<<<$main_cmd) ]] && return 0 [[ $COMP_LINE =~ $( tr ' ' '|'<<<$main_cmd ) ]] && return
COMPREPLY=( $( compgen -W "$all_cmd" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$all_cmd" -- "$cur" ) )
return 0
} && } &&
complete -F _gnokii gnokii complete -F _gnokii gnokii