diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-27 19:41:28 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-27 19:49:58 +0100 |
commit | 1e4a96730da70fcfa3b8c153874cbdebad0f9829 (patch) | |
tree | 9495f33f6b54621e0a684b553b64a6958744c1e3 /bin | |
parent | e1daac32c5b7ca0d902c16135d361aa5303f5124 (diff) | |
download | app.sh-1e4a96730da70fcfa3b8c153874cbdebad0f9829.tar.gz app.sh-1e4a96730da70fcfa3b8c153874cbdebad0f9829.tar.bz2 app.sh-1e4a96730da70fcfa3b8c153874cbdebad0f9829.tar.xz app.sh-1e4a96730da70fcfa3b8c153874cbdebad0f9829.zip |
o Starting on a style guide.
app-conf: Adding 'import' command.
app-cat-conf: Adding support for multiple -f flags. The default files
can be switched off.
A file named "-" is the same as /dev/stdin.
app: Adding a way to enable debugging.
app-install-file: Import any configuration delivered with the package.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/app-conf | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/bin/app-conf b/bin/app-conf index 3602a39..d281740 100755 --- a/bin/app-conf +++ b/bin/app-conf @@ -61,8 +61,16 @@ conf_delete() { mv $file.tmp $file } +conf_import() { + local dst=$1; shift + local src=$1; shift + + app-cat-conf -f "$src" -f "$dst" > "$dst.tmp" + mv "$dst.tmp" "$dst" +} + usage() { - if [ -n "$1" ] + if [ $# -gt 0 ] then echo "Error: $@" >&2 fi @@ -70,12 +78,16 @@ usage() { echo "usage: $0 conf <command>" >&2 echo "" echo "Available commands:" >&2 + echo " get [name] - returns a single value" >&2 echo " list - list all config values" >&2 echo " set [name] [value] - set a config parameter" >&2 echo " delete [name] - deletes a config parameter" >&2 + echo " import [file] - import a file" >&2 exit 1 } +file=".app/config" + if [ $# -gt 0 ] then command=$1 @@ -84,8 +96,6 @@ else command=list fi -file=".app/config" - assert_is_app -C case "$command" in @@ -93,7 +103,6 @@ case "$command" in if [ $# != 1 ] then usage - exit 1 fi app-cat-conf -f "$file" -n "$1" | cut -f 2 -d = | format_conf | sed "s, *$,," @@ -102,7 +111,6 @@ case "$command" in if [ $# -gt 0 ] then usage "Extra options." - exit 1 fi app-cat-conf -f "$file" | format_conf @@ -111,7 +119,6 @@ case "$command" in if [ $# -ne 2 ] then usage - exit 1 fi conf_set "$1" "$2" @@ -120,11 +127,19 @@ case "$command" in if [ $# -ne 1 ] then usage "Missing [name] argument." - exit 1 fi conf_delete "$1" ;; + import) + if [ $# -ne 1 ] + then + usage "Missing [file] argument." + exit 1 + fi + + conf_import "$file" "$1" + ;; *) if [ -z "$command" ] then |