2022-06-22 23:54:21 +08:00
|
|
|
function __fish_qdbus_complete
|
2024-01-28 03:08:53 +08:00
|
|
|
argparse system 'bus=' literal help -- (commandline --cut-at-cursor --tokens-expanded) 2>/dev/null
|
2022-06-22 23:54:21 +08:00
|
|
|
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
|
2023-05-06 16:04:03 +08:00
|
|
|
qdbus $qdbus_flags $argv[2] $argv[3] | string replace --regex '^(?<kind>property\ (read)?(write)?|signal|method( Q_NOREPLY)?) (?<type>(\{.+\})|([^\ ]+)) (?<name>[^\(]+)(?<arguments>\(.+?\))?' '$name\t$kind $type $arguments' | string trim
|
2022-06-22 23:54:21 +08:00
|
|
|
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)'
|