From e4e4e4954c3b49fd3951964c20fdd9cb149d561e Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Tue, 13 Aug 2019 20:27:56 -0700 Subject: [PATCH] shell-completion: complete --match argument for busctl --- shell-completion/zsh/_busctl | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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]' \