mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
shell-completion: complete --match argument for busctl
This commit is contained in:
parent
161719d50c
commit
e4e4e4954c
@ -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]' \
|
||||
|
Loading…
Reference in New Issue
Block a user