From: Amand Tihon Date: Thu, 6 Dec 2012 10:15:46 +0000 (+0100) Subject: Add completion function for the python dbus CLI X-Git-Url: https://git.alrj.org/?a=commitdiff_plain;h=cd66ae2212b8ba87ff1ba93241521c4f56615edb;p=zsh.d.git Add completion function for the python dbus CLI --- diff --git a/functions/_dbus b/functions/_dbus new file mode 100644 index 0000000..c07d7cc --- /dev/null +++ b/functions/_dbus @@ -0,0 +1,51 @@ +#compdef dbus + +# Completion for dbus python client +# http://code.google.com/p/dbus-tools/source/browse/trunk/_dbus + +local count="$#words" +local opts=0 + +for word in $words[2,-2] ; do + case $word in + -*) + (( opts += 1 )) + ;; + *) + break + ;; + esac +done + +if (( opts == count - 2 )) ; then + if [[ $words[-1] = -* ]] ; then + _arguments -C \ + {-a,--all}'[Equivalent to -e -s -t -u]' \ + {-e,--empty}'[Also show empty services/objects]' \ + {-h,--help}'[Print help]' \ + {-s,--signals}'[Print signals]' \ + {-t,--activatables}'[Also show activatables services]' \ + {-u,--unnamed}'[Also show unnamed services]' \ + {-y,--system-bus}'[Use system bus]' + return + fi +fi + +case $((count - 2 - $opts)) in + 0) + _message "service" + ;; + 1) + _message "object" + ;; + 2) + _message "method" + ;; + *) + _wanted file expl "`dbus -c $words[2,-2]`" _files + return +esac + +compadd `dbus -c $words[2,-2]` + +return