summaryrefslogtreecommitdiff
path: root/shell-completion
diff options
context:
space:
mode:
authorRonan Pigott <rpigott@berkeley.edu>2019-08-13 20:27:56 -0700
committerRonan Pigott <rpigott@berkeley.edu>2019-08-13 20:27:56 -0700
commite4e4e4954c3b49fd3951964c20fdd9cb149d561e (patch)
tree5c99d7691e48cb7758df571bbbeb713c8cc76b09 /shell-completion
parent161719d50c43d09a5bc897abc8613c59da6a5b6e (diff)
downloadsystemd-e4e4e4954c3b49fd3951964c20fdd9cb149d561e.tar.gz
shell-completion: complete --match argument for busctl
Diffstat (limited to 'shell-completion')
-rw-r--r--shell-completion/zsh/_busctl26
1 files changed, 25 insertions, 1 deletions
diff --git a/shell-completion/zsh/_busctl b/shell-completion/zsh/_busctl
index 9c3654316e..0589e99326 100644
--- a/shell-completion/zsh/_busctl
+++ b/shell-completion/zsh/_busctl
@@ -50,6 +50,19 @@ __busctl() {
busctl $_bus_address --no-pager --no-legend "$@" 2>/dev/null
}
+__dbus_matchspec() {
+ # https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing
+ _values -s, 'rules' \
+ 'type[Match on message type]:type:(signal method_call method_return error)' \
+ 'eavesdrop[Include unicast messages]:bool:(true false)' \
+ 'sender[Match messages sent by a particular sender]:sender:{compadd $(_busctl_get_service_names)}'\
+ 'interface[Match messages sent over or to a particular interface]:interface' \
+ 'member[Match messages which have the given method or signal name]:member' \
+ 'path[Match messages which are sent from or to the given object]:path' \
+ 'path_namespace[Match messages which are sent from or to the given namespace]:namespace' \
+ 'destination[Match messaged sent to the given unique name]:unique name:{compadd $(_busctl_get_unique_names)}'
+}
+
(( $+functions[_busctl_get_json] )) || _busctl_get_json()
{
local -a _json_forms
@@ -68,6 +81,16 @@ __busctl() {
echo ${(Q)bus_names[3,-1]}
}
+(( $+functions[_busctl_get_unique_names] )) || _busctl_get_unique_names()
+{
+ local -a bus_names
+ local NAME OTHER
+ __busctl --unique list |
+ while read NAME OTHER; do
+ echo $NAME
+ done
+}
+
(( $+functions[_busctl_get_objects] )) || _busctl_get_objects()
{
local -a objects
@@ -234,6 +257,7 @@ __busctl() {
local -a _modes; _modes=("--user" "--system")
# Use the last mode (they are exclusive and the last one is used).
local _bus_address=${${words:*_modes}[(R)(${(j.|.)_modes})]}
+local curcontext=$curcontext state line
_arguments \
{-h,--help}'[Prints a short help text and exits.]' \
'--version[Prints a short version string and exits.]' \
@@ -248,7 +272,7 @@ _arguments \
'--unique[Only show unique names]' \
'--acquired[Only show acquired names]' \
'--activatable[Only show activatable names]' \
- '--match=[Only show matching messages]:match' \
+ '--match=[Only show matching messages]:match:__dbus_matchspec' \
'--list[Do not show tree, but simple object path list]' \
{-q,--quiet}'[Do not show method call reply]'\
'--verbose[Show result values in long format]' \