[Bash-completion-commits] [bash-completion] 01/05: gnokii: New completion
Ville Skyttä
scop-guest at moszumanska.debian.org
Mon May 11 09:22:53 UTC 2015
This is an automated email from the git hooks/post-receive script.
scop-guest pushed a commit to branch master
in repository bash-completion.
commit 3eb1b0dda81f2bc15a6c4f104cb5f0d2169c3101
Author: Raphaël Droz <raphael.droz+floss at gmail.com>
Date: Mon May 11 11:58:19 2015 +0300
gnokii: New completion
http://lists.alioth.debian.org/pipermail/bash-completion-devel/2012-October/004634.html
---
completions/gnokii | 233 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 233 insertions(+)
diff --git a/completions/gnokii b/completions/gnokii
new file mode 100644
index 0000000..3ff82c9
--- /dev/null
+++ b/completions/gnokii
@@ -0,0 +1,233 @@
+# gnokii(1) completion
+
+_gnokii_memory_type() {
+ # TODO: reduce the number of choices
+ COMPREPLY=( $( compgen -W "IN OU SM ME MT" -- "$cur" ) )
+}
+_gnokii_folder_ids() {
+ gnokii --showsmsfolderstatus
+}
+
+_gnokii() {
+ local cur prev words cword pprev tprev fprev
+ _init_completion || return
+
+ case $prev in
+ --config)
+ _filedir
+ return 0
+ ;;
+ --phone)
+ local config_file="$XDG_CONFIG_HOME/gnokii/config"
+ [[ ! -f $config_file ]] && config_file="$HOME/.config/gnokii/config"
+ [[ ! -f $config_file ]] && config_file="$HOME/.gnokiirc"
+ [[ ! -f $config_file ]] && config_file="$XDG_CONFIG_DIRS/gnokii/config"
+ [[ ! -f $config_file ]] && config_file=/etc/gnokiirc
+ [[ ! -f $config_file ]] && return 0
+ COMPREPLY=( $( compgen -W "$(sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file)" \
+ -- "$cur" ) )
+ return 0
+ ;;
+ --help)
+ COMPREPLY=( $( compgen -W 'all monitor sms mms phonebook calendar todo \
+ dial profile settings wap logo ringtone security \
+ file other' -- "$cur" ) )
+ return 0
+ ;;
+ # no argument
+ --version|--shell|ping)
+ return 0
+ ;;
+ # MONITOR
+ --monitor)
+ COMPREPLY=( $( compgen -W 'delay once' -- "$cur" ) )
+ return 0
+ ;;
+ # no argument
+ --getdisplaystatus|--displayoutput)
+ return 0
+ ;;
+ --netmonitor)
+ COMPREPLY=( $( compgen -W 'reset off field devel next nr' -- "$cur" ) )
+ return 0
+ ;;
+
+ # SMS
+ --sendsms)
+ # (how)TODO ?
+ return 0
+ ;;
+ --savesms)
+ COMPREPLY=( $( compgen -W '--sender --smsc --smscno --folder --location \
+ --sent --read --deliver --datetime' -- $cur ) )
+ return 0
+ ;;
+ --memory-type|--memory|--getsms|--deletesms|--getmms|--deletemms| \
+ --getphonebook|--deletephonebook)
+ _gnokii_memory_type
+ return 0
+ ;;
+ --getsmsc|--getcalendarnote|--deletecalendarnote|--gettodo|--getspeeddial)
+ # TODO: grab a specific entry ID
+ return 0
+ ;;
+ # no argument
+ --setsmsc|--smsreader|--createsmsfolder|--deletealltodos|--showsmsfolderstatus)
+ return 0
+ ;;
+ --deletesmsfolder|--folder)
+ # TODO: folderid
+ return 0
+ ;;
+ --writephonebook)
+ COMPREPLY=( $( compgen -W '--overwrite --find-free --memory-type \
+ --location --vcard --ldif' -- $cur ) )
+ return 0
+ ;;
+ --writecalendarnote|--writetodo)
+ _filedir vcf
+ return 0
+ ;;
+
+ # DIAL
+ --setspeeddial|--dialvoice|--senddtmf|--answercall|--hangup)
+ # TODO
+ return 0
+ ;;
+ --divert)
+ COMPREPLY=( $( compgen -W '--op' -- "$cur" ) )
+ return 0
+ ;;
+
+ # PROFILE
+ --getprofile|--setactiveprofile)
+ # TODO
+ return 0
+ ;;
+ --setprofile|--getactiveprofile)
+ return 0
+ ;;
+
+ # SETTINGS
+ --reset)
+ COMPREPLY=( $( compgen -W 'soft hard' -- "$cur" ) )
+ return 0
+ ;;
+ --setdatetime|--setalarm)
+ # TODO
+ return 0
+ ;;
+ --getdatetime|--getalarm)
+ return 0
+ ;;
+
+ # WAP
+ --getwapbookmark|--writewapbookmark|--deletewapbookmark|--getwapsetting| \
+ --writewapsetting|--activatewapsetting)
+ return 0
+ ;;
+
+ # LOGOS
+ --sendlogo)
+ COMPREPLY=( $( compgen -W 'caller op picture' -- "$cur" ) )
+ return 0
+ ;;
+ --setlogo|--getlogo)
+ COMPREPLY=( $( compgen -W 'op startup caller dealer text' -- "$cur" ) )
+ return 0
+ ;;
+ --viewlogo)
+ # TODO: logofile
+ return 0
+ ;;
+
+ --entersecuritycode)
+ COMPREPLY=( $( compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur" ) )
+ return 0
+ ;;
+
+ # 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 0
+ ;;
+ --getsms|--deletesms|--getmms|--deletemms|--getphonebook|--writetodo| \
+ --writecalendarnote)
+ # TODO: start number
+ return 0
+ ;;
+ --gettodo|--getcalendarnote)
+ COMPREPLY=( $( compgen -W '{1..9} end --vCal' -- "$cur" ) )
+ return 0
+ ;;
+ --deletecalendarnote)
+ COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) )
+ return 0
+ ;;
+ --divert)
+ COMPREPLY=( $( compgen -W 'register enable query disable erasure' \
+ -- "$cur" ) )
+ return 0
+ ;;
+ 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 0
+ ;;
+ --getphonebook|--writetodo|--writecalendarnote)
+ COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) )
+ return 0
+ ;;
+ --gettodo|--getcalendarnote)
+ [[ ${words[$((cword-1))]} = end ]] && \
+ COMPREPLY=( $( compgen -W '--vCal' -- "$cur" ) )
+ return 0
+ ;;
+ --divert)
+ COMPREPLY=( $( compgen -W '--type' -- "$cur" ) )
+ return 0
+ 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 0
+ ;;
+ --divert)
+ COMPREPLY=( $( compgen -W 'all busy noans outofreach notavail' \
+ -- "$cur" ) )
+ return 0
+ 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=$(echo "$a"|grep -v -- '--config\|--phone')
+
+ # don't provide main command completions if one is
+ # already on the command line
+ [[ $COMP_LINE =~ $(tr ' ' '|'<<<$main_cmd) ]] && return 0
+
+ COMPREPLY=( $( compgen -W "$all_cmd" -- "$cur" ) )
+ return 0
+} &&
+complete -F _gnokii gnokii
+
+# ex: ts=4 sw=4 et filetype=sh
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git
More information about the Bash-completion-commits
mailing list