completions: add qdbus completion

(cherry picked from commit c588bd5c5c)
This commit is contained in:
Rocka 2022-06-22 23:54:21 +08:00 committed by David Adam
parent 1c3a8e0e11
commit bc30e15774
2 changed files with 26 additions and 1 deletions

View File

@ -5,7 +5,7 @@ This release of fish introduces the following small enhancements:
- Cursor shaping for Vi mode is enabled by default in tmux, and will be used if the outer terminal is capable (:issue:`8981`).
- ``printf`` returns a better error when used with arguments interpreted as octal numbers (:issue:`9035`).
- New completions for ``reflector`` (:issue:`9027`) and improvements to some completions.
- New completions for ``qdbus`` (:issue:`9031:`) and ``reflector`` (:issue:`9027`), and improvements to some completions.
This release also fixes a number of problems identified in fish 3.5.0.

View File

@ -0,0 +1,25 @@
function __fish_qdbus_complete
argparse system 'bus=' literal help -- (commandline --cut-at-cursor --tokenize) 2>/dev/null
or return
if set -q _flag_help
return
end
set -l qdbus_flags $_flag_system
if set -q _flag_bus
set -a qdbus_flags --bus $_flag_bus
end
set argc (count $argv)
if test $argc -le 3
# avoid completion of property value
qdbus $qdbus_flags $argv[2] $argv[3] | string replace --regex '^(property(\ read)?|signal|method) ((\{.+\})|([^\ ]+)) ([^\(]+)(\(.+?\))?' '$6\t$1 $3 $7' | string trim
end
end
complete -c qdbus -f
complete -c qdbus -l system -d 'connect to the system bus'
complete -c qdbus -l bus -r -d 'connect to a custom bus'
complete -c qdbus -l literal -d 'print replies literally'
complete -c qdbus -l help -d 'print usage'
complete -c qdbus -a '(__fish_qdbus_complete)'