Debian Codegraph @

gio/completion/gdbus

raw
1 #
2 # Copyright 2010 Red Hat, Inc.
3 #
4 # This library is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU Lesser General Public License as
6 # published by the Free Software Foundation; either version 2.1 of the
7 # licence, or (at your option) any later version.
8 #
9 # This is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12 # License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, see <http://www.gnu.org/licenses/>.
16 #
17 # SPDX-License-Identifier: LGPL-2.1-or-later
18
19 # shellcheck shell=bash
20
21 # Check for bash
22 [ -z "$BASH_VERSION" ] && return
23
24 ####################################################################################################
25
26
27 __gdbus() {
28 local gdbus_binary
29 gdbus_binary="$1"
30
31 local IFS=$'\n'
32 local cur
33 cur="$(_get_cword :)"
34
35 local suggestions
36 suggestions="$("$gdbus_binary" complete "${COMP_LINE}" "${COMP_POINT}")"
37 # shellcheck disable=SC2207
38 COMPREPLY=($(compgen -W "$suggestions" -- "$cur"))
39
40 # Remove colon-word prefix from COMPREPLY items
41 case "$cur" in
42 *:*)
43 case "$COMP_WORDBREAKS" in
44 *:*)
45 local colon_word=${cur%"${cur##*:}"}
46 local i=${#COMPREPLY[*]}
47 while [ $((--i)) -ge 0 ]; do
48 COMPREPLY[i]=${COMPREPLY[i]#"$colon_word"}
49 done
50 ;;
51 esac
52 ;;
53 esac
54 }
55
56 ####################################################################################################
57
58 complete -o nospace -F __gdbus gdbus