about summary refs log tree commit diff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2012-09-27 23:33:57 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2012-09-27 23:33:57 +0000
commit1ca9f9d5d0e2a84809e99de62e5f4b7a1f809ab2 (patch)
tree84bb409adf7d3d160abeff047e7e6eae5de8ad33 /Completion/Unix/Command
parentdbec4fa6ccccb717608498b83989b21967948bde (diff)
downloadzsh-1ca9f9d5d0e2a84809e99de62e5f4b7a1f809ab2.tar.gz
zsh-1ca9f9d5d0e2a84809e99de62e5f4b7a1f809ab2.tar.xz
zsh-1ca9f9d5d0e2a84809e99de62e5f4b7a1f809ab2.zip
30697: new completion definition for dbus-send and dbus-monitor
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_dbus87
1 files changed, 87 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_dbus b/Completion/Unix/Command/_dbus
new file mode 100644
index 000000000..bdd7613f0
--- /dev/null
+++ b/Completion/Unix/Command/_dbus
@@ -0,0 +1,87 @@
+#compdef dbus-send dbus-monitor
+
+local curcontext="$curcontext" state line expl find end ret=1
+typeset -A opt_args
+local -a suf introspect interfaces
+
+case $service in
+  dbus-send)
+    _arguments -A "--*" -C \
+      '(--session)--system' '(--system)--session' \
+      '--address=-:bus address:->addresses' \
+      '--dest=-:connection:->connections' \
+      '--print-reply=-::format:(literal)' \
+      '--reply-timeout=-:timeout (ms)' \
+      '--type=-:type:(method_call signal)' \
+      ':object path:->objectpaths' \
+      ':message name:->methods' \
+      ':content:->contents' && ret=0
+  ;;
+  dbus-monitor)
+    _arguments -A "--*" -C \
+      '(--session)--system' '(--system)--session' \
+      '--address=-:bus address:->addresses' \
+      '(--profile)--monitor' '(--monitor)--profile' \
+      '*:watch expression:->expressions' && ret=0
+  ;;
+esac
+
+case $state in
+  addresses)
+    compset -P '*;'
+    if compset -P '*='; then
+      _files  && ret=0
+    else
+      _message -e addresses address
+    fi
+  ;;
+  connections)
+    _wanted connections expl connection compadd ${=${(M)PREFIX:#*.*}:+-M 'r:|.=* r:|=*'} ${$(_call_program connections dbus-send ${opt_args[(I)--system]} --print-reply=literal --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames 2>/dev/null):#(array|\[|\])} ${$(_call_program connections dbus-send ${opt_args[(I)--system]} --print-reply=literal --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames 2>/dev/null):#(array|\[|\])} && ret=0
+  ;;
+  objectpaths)
+    if [[ -prefix / ]]; then
+      compset -P ${PREFIX%%[^/]#}
+      _wanted objectpaths expl 'object path' compadd -qS/ ${${${(M)${(f)"$(_call_program objectpaths dbus-send --print-reply ${(M)words:#(--dest=|--system|--address=)*} ${${IPREFIX%/}:-/} org.freedesktop.DBus.Introspectable.Introspect 2>/dev/null)"}:#*node name=[^/]##\"*}#*\"}%\"*} && ret=0
+    else
+      _wanted objectpaths expl 'object path' compadd -S '/' -r '-=' '' && ret=0
+    fi
+  ;;
+  methods)
+    introspect=( ${(M)${(f)"$(_call_program methods dbus-send --print-reply ${(M)words:#(--dest=|--system|--address=|/)*} org.freedesktop.DBus.Introspectable.Introspect 2>/dev/null)"}:#*name=*} )
+    interfaces=( ${${${(M)introspect:#*interface name=*}#*\"}%\"*} )
+    _wanted interfaces expl interface compadd -qS. -M 'r:|.=* r:|=*' -a interfaces && ret=0
+    if [[ $compstate[nmatches] != $#interfaces ]] && compset -P '*.'; then
+      find="*interface name=?${IPREFIX%.}??"
+      end=${interfaces[(i)${IPREFIX%.}]}
+      _wanted methods expl method compadd ${${${(M)${${introspect[${introspect[(i)$find]}+1,(in.end+1.)*interface name=*]}:#*interface name=*}:#*${${opt_args[--type]%_*}:-method} name=*}#*\"}%\"*} && ret=0
+    fi
+  ;;
+  contents)
+    compset -S ':*' || suf=( -S : )
+    while compset -P '(array|dict|variant):'; do
+      :
+    done
+    if compset -P '*:'; then
+      _message -e value 'value'
+    else
+      _alternative -O suf \
+        'containers:container:(array dict variant)' \
+	'types:type:(string double byte boolean objpath '${(j. .):-{,u}int{16,32,64}}\) && ret=0
+    fi
+  ;;
+  expressions)
+    _values -w -s , 'expression' \
+      'type:message type:(signal method_call method_return error)' \
+      'sender:bus or name' \
+      'interface:interface' \
+      'member:member' \
+      'path:path' \
+      'path_namespace:path' \
+      'destination:unique name' \
+      arg{0..9}:value \
+      'arg0namespace:namespace' \
+      'eavesdrop:eavesdropping:(true false)' && ret=0
+  ;;
+esac
+
+return ret