summaryrefslogtreecommitdiffstats
path: root/shell-completion/zsh/_varlinkctl
diff options
context:
space:
mode:
authorRonan Pigott <ronan@rjp.ie>2024-07-19 17:35:46 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2024-07-19 23:07:37 +0200
commit09a8a0d0230587ecebe97f3284e9717fcbf14f8c (patch)
tree6e34709ab5747cf7dbef0381ed1a4144471bfb61 /shell-completion/zsh/_varlinkctl
parentexecute: add FIXME comment (diff)
downloadsystemd-09a8a0d0230587ecebe97f3284e9717fcbf14f8c.tar.xz
systemd-09a8a0d0230587ecebe97f3284e9717fcbf14f8c.zip
zsh: update varlinkctl completions
correct redundant or mismatched tags and fill the argument field of curcontext because _regex_words does not do that for us. The _complete_help text now looks much more reasonable most of the time: $ varlinkctl call /run/systemd/resolve/io.systemd.Resolve ^Xh tags in context :completion::complete:varlinkctl:: argument-rest (_arguments _varlinkctl) tags in context :completion::complete:varlinkctl-call:method: varlink-methods (_varlinkctl_cmd _varlinkctl_command _arguments _varlinkctl) Fixes: af63b4b769bf ("zsh: add varlinkctl completions")
Diffstat (limited to '')
-rw-r--r--shell-completion/zsh/_varlinkctl34
1 files changed, 26 insertions, 8 deletions
diff --git a/shell-completion/zsh/_varlinkctl b/shell-completion/zsh/_varlinkctl
index 720700d04a..c904ebd711 100644
--- a/shell-completion/zsh/_varlinkctl
+++ b/shell-completion/zsh/_varlinkctl
@@ -4,27 +4,25 @@
local -a reply line
_varlinkctl_interfaces() {
- local expl
- _wanted varlink-interfaces expl interface compadd "$@" -- \
+ compadd "$@" -- \
"${(@f)$(_call_program varlink-interfaces varlinkctl list-interfaces $line[2])}"
}
_varlinkctl_methods() {
- local expl
- _wanted varlink-interfaces expl method compadd "$@" -- \
+ compadd "$@" -- \
"${(@f)$(_call_program varlink-methods varlinkctl list-methods $line[2])}"
}
local -a varlink_addr=(
- /$'[^\0]#\0'/ ':varlink-address:varlink address:_files -g "*(=)"'
+ /$'[^\0]#\0'/ ':varlink-addresses:varlink address:_files -g "*(=)"'
)
local -a varlink_interface=(
$varlink_addr
- /$'[^\0]#\0'/ ':varlink-interface:varlink interface:_varlinkctl_interfaces'
+ /$'[^\0]#\0'/ ':varlink-interfaces:varlink interface:_varlinkctl_interfaces'
)
local -a varlink_method=(
$varlink_addr
- /$'[^\0]#\0'/ ':varlink-method:varlink method:_varlinkctl_methods'
+ /$'[^\0]#\0'/ ':varlink-methods:varlink method:_varlinkctl_methods'
)
local -a varlink_call=($varlink_method /$'[^\0]#\0'/ ':argument:argument:()')
local -a varlink_idl=(/$'[^\0]#\0'/ ':varlink-idl-file:idl file:_files')
@@ -39,7 +37,27 @@ _regex_words varlink-commands 'varlink command' \
'help:show a help message'
local -a varlinkcmd=( /$'[^\0]#\0'/ "$reply[@]" )
-_regex_arguments _varlinkctl_command "$varlinkcmd[@]"
+_regex_arguments _varlinkctl_cmd "$varlinkcmd[@]"
+
+_varlinkctl_command() {
+ local varlink_command=varlinkctl
+ ((CURRENT > 2 )) && varlink_command=varlinkctl-$line[1]
+
+ local -a varlink_args
+ case "$line[1]" in
+ (info|list-interfaces)
+ varlink_args=(address) ;;
+ (introspect|list-methods)
+ varlink_args=(address interface) ;;
+ (call)
+ varlink_args=(address method arguments) ;;
+ (validate-idl)
+ varlink_args=(file) ;;
+ esac
+
+ curcontext="${curcontext%:*:*}:$varlink_command:$varlink_args[CURRENT-2]"
+ _varlinkctl_cmd "$@"
+}
local -a opts=(
{-h,--help}'[Show a help message and exit]'