Add some more cases to the app-id unit tests
[glib.git] / gio / completion / gsettings
blob0316e299f0f16fb072b3aca13184ed2462dad273
2 # Check for bash
3 [ -z "$BASH_VERSION" ] && return
5 ####################################################################################################
7 __gsettings() {
8   local choices coffset schemadir
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
22   case "$((${COMP_CWORD}-$coffset))" in
23     1)
24       choices=$'--schemadir\n--version\nhelp \nlist-schemas\nlist-relocatable-schemas\nlist-keys \nlist-children \nlist-recursively \nget \nrange \nset \nreset \nreset-recursively \nwritable \nmonitor \ndescribe '
25       ;;
27     2)
28       case "${COMP_WORDS[$(($coffset+1))]}" in
29         --schemadir)
30           COMPREPLY=($(compgen -o dirnames -- ${COMP_WORDS[${COMP_CWORD}]}))
31           return 0
32           ;;
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           ;;
41         get|range|set|reset|writable|monitor|describe)
42           choices="$(gsettings $schemadir list-schemas | sed -e 's.$. .')"$'\n'"$(gsettings $schemadir list-relocatable-schemas | sed -e 's.$.:/.')"
43           ;;
44       esac
45       ;;
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           ;;
53         get|range|reset|writable|monitor|describe)
54           choices="$(gsettings $schemadir list-keys ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null)"
55           ;;
56       esac
57       ;;
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
78   local IFS=$'\n'
79   COMPREPLY=($(compgen -W "${choices}" -- "${COMP_WORDS[${COMP_CWORD}]}"))
82 ####################################################################################################
84 complete -o nospace -F __gsettings gsettings