gio/tests/pollable: add can_poll() assertions
[platform/upstream/glib.git] / gio / completion / gsettings
1
2 # Check for bash
3 [ -z "$BASH_VERSION" ] && return
4
5 ####################################################################################################
6
7 __gsettings() {
8   local choices coffset schemadir
9
10   if [ ${COMP_CWORD} -gt 2 ]; then
11       if [ ${COMP_WORDS[1]} = --schemadir ]; then
12           # this complexity is needed to perform correct tilde expansion
13           schemadir=$(eval "echo --schemadir ${COMP_WORDS[2]}")
14           coffset=2
15       else
16           coffset=0
17       fi
18   else
19       coffset=0
20   fi
21
22   case "$((${COMP_CWORD}-$coffset))" in
23     1)
24       choices=$'--schemadir\nhelp \nlist-schemas\nlist-relocatable-schemas\nlist-keys \nlist-children \nlist-recursively \nget \nrange \nset \nreset \nreset-recursively \nwritable \nmonitor'
25       ;;
26
27     2)
28       case "${COMP_WORDS[$(($coffset+1))]}" in
29         --schemadir)
30           COMPREPLY=($(compgen -o dirnames -- ${COMP_WORDS[${COMP_CWORD}]}))
31           return 0
32           ;;
33
34         help)
35           choices=$'list-schemas\nlist-relocatable-schemas\nlist-keys\nlist-children\nlist-recursively\nget\nrange\nset\nreset\nreset-recursively\nwritable\nmonitor'
36           ;;
37         list-keys|list-children|list-recursively|reset-recursively)
38           choices="$(gsettings $schemadir list-schemas)"$'\n'"$(gsettings $schemadir list-relocatable-schemas | sed -e 's.$.:/.')"
39           ;;
40
41         get|range|set|reset|writable|monitor)
42           choices="$(gsettings $schemadir list-schemas | sed -e 's.$. .')"$'\n'"$(gsettings $schemadir list-relocatable-schemas | sed -e 's.$.:/.')"
43           ;;
44       esac
45       ;;
46
47     3)
48       case "${COMP_WORDS[$(($coffset+1))]}" in
49         set)
50           choices="$(gsettings $schemadir list-keys ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null | sed -e 's.$. .')"
51           ;;
52
53         get|range|reset|writable|monitor)
54           choices="$(gsettings $schemadir list-keys ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null)"
55           ;;
56       esac
57       ;;
58
59     4)
60       case "${COMP_WORDS[$(($coffset+2))]}" in
61         set)
62           range=($(gsettings $schemadir range ${COMP_WORDS[$(($coffset+2))]} ${COMP_WORDS[$(($coffset+3))]} 2> /dev/null))
63           case "${range[0]}" in
64             enum)
65               unset range[0]
66              ;;
67             *)
68               unset range
69              ;;
70           esac
71           local IFS=$'\n'
72           choices="${range[*]}"
73           ;;
74       esac
75       ;;
76   esac
77
78   local IFS=$'\n'
79   COMPREPLY=($(compgen -W "${choices}" -- "${COMP_WORDS[${COMP_CWORD}]}"))
80 }
81
82 ####################################################################################################
83
84 complete -o nospace -F __gsettings gsettings