mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 00:06:24 +01:00
gsettings-tool: Rewrite
Rewrite the GSettings tool. Improvements/changes: - simplify the code by performing common actions (like creating a schema) in only one place instead of one per-command - new features (list schemas, list keys, monitor multiple, etc) - factor-out bash completion and implement in shellscript - input validation: should never abort due to invalid inputs Still to do: - proper error checking for ranges/choices - support for querying range/choice information - bash completion support for enums Closes bug #629289, possibly among others.
This commit is contained in:
parent
ed9db23f9a
commit
2d6f8a8ea4
@ -4,28 +4,44 @@
|
|||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
|
|
||||||
__gsettings() {
|
__gsettings() {
|
||||||
|
local choices
|
||||||
|
|
||||||
|
case "${COMP_CWORD}" in
|
||||||
|
1)
|
||||||
|
choices=$'help \nlist-schemas\nlist-relocatable-schemas\nlist-keys \nlist-children \nget \nset \nreset \nwritable \nmonitor'
|
||||||
|
;;
|
||||||
|
|
||||||
|
2)
|
||||||
|
case "${COMP_WORDS[1]}" in
|
||||||
|
help)
|
||||||
|
choices=$'list-schemas\nlist-relocatable-schemas\nlist-keys\nlist-children\nget\nset\nreset\nwritable\nmonitor'
|
||||||
|
;;
|
||||||
|
list-keys|list-children)
|
||||||
|
choices="$(gsettings list-schemas)"$'\n'"$(gsettings list-relocatable-schemas | sed -e 's.$.:/.')"
|
||||||
|
;;
|
||||||
|
|
||||||
|
get|set|reset|writable|monitor)
|
||||||
|
choices="$(gsettings list-schemas | sed -e 's.$. .')"$'\n'"$(gsettings list-relocatable-schemas | sed -e 's.$.:/.')"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
3)
|
||||||
|
case "${COMP_WORDS[1]}" in
|
||||||
|
set)
|
||||||
|
choices="$(gsettings list-keys ${COMP_WORDS[2]} 2> /dev/null | sed -e 's.$. .')"
|
||||||
|
;;
|
||||||
|
|
||||||
|
get|reset|writable|monitor)
|
||||||
|
choices="$(gsettings list-keys ${COMP_WORDS[2]} 2> /dev/null)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local cur=`_get_cword :`
|
COMPREPLY=($(compgen -W "${choices}" "${COMP_WORDS[$COMP_CWORD]}"))
|
||||||
|
|
||||||
local suggestions=$(gsettings complete "${COMP_LINE}" ${COMP_POINT})
|
|
||||||
COMPREPLY=($(compgen -W "$suggestions" -- "$cur"))
|
|
||||||
|
|
||||||
# Remove colon-word prefix from COMPREPLY items
|
|
||||||
case "$cur" in
|
|
||||||
*:*)
|
|
||||||
case "$COMP_WORDBREAKS" in
|
|
||||||
*:*)
|
|
||||||
local colon_word=${cur%${cur##*:}}
|
|
||||||
local i=${#COMPREPLY[*]}
|
|
||||||
while [ $((--i)) -ge 0 ]; do
|
|
||||||
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
1155
gio/gsettings-tool.c
1155
gio/gsettings-tool.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user