From bc30e15774538e7878568d1551dada13b0f395d9 Mon Sep 17 00:00:00 2001 From: Rocka Date: Wed, 22 Jun 2022 23:54:21 +0800 Subject: [PATCH] completions: add qdbus completion (cherry picked from commit c588bd5c5cffa71cbdebd4fd1498ab5554fdb68a) --- CHANGELOG.rst | 2 +- share/completions/qdbus.fish | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 share/completions/qdbus.fish diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c69532f3d..4956afdbc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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. diff --git a/share/completions/qdbus.fish b/share/completions/qdbus.fish new file mode 100644 index 000000000..cfee1cd5e --- /dev/null +++ b/share/completions/qdbus.fish @@ -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)'