aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-10-20 18:09:50 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-10-20 20:23:30 +0200
commit11cf17750885324a58a68d237b0ac29bc3a6269b (patch)
tree474da312f12a82629b495b5901c10ea49b08e98c /lib
parentd2e3a3795f345fd78ead2cf06b1134b46f9d4bc4 (diff)
downloadapp.sh-11cf17750885324a58a68d237b0ac29bc3a6269b.tar.gz
app.sh-11cf17750885324a58a68d237b0ac29bc3a6269b.tar.bz2
app.sh-11cf17750885324a58a68d237b0ac29bc3a6269b.tar.xz
app.sh-11cf17750885324a58a68d237b0ac29bc3a6269b.zip
o Making all app-conf options except import use <-l location>.
o Setting $HOME to the temporary area when testing. o Adding test docs for app-conf.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/common47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/common b/lib/common
index d2d29c8..9e0db84 100755
--- a/lib/common
+++ b/lib/common
@@ -159,6 +159,53 @@ find_versions() {
)
}
+validate_location() {
+ local name=$1; shift
+
+ case "${!name}" in
+ s|system)
+ eval ${name}=1
+ ;;
+ u|user)
+ eval ${name}=2
+ ;;
+ a|app)
+ eval ${name}=3
+ ;;
+ *)
+ fatal "Invalid location: ${!name}, must be one of 's', 'system', 'u', 'user', 'a' or 'app'."
+ ;;
+ esac
+}
+
+location_to_file() {
+ case "${!1}" in
+ s|system|1)
+ _get_config_file_system $1
+ ;;
+ u|user|2)
+ _get_config_file_user $1
+ ;;
+ a|app|3)
+ _get_config_file_app $1
+ ;;
+ *)
+ fatal "Invalid location: ${!1}, must be one of 's', 'system', 'u', 'user', 'a' or 'app'."
+ esac
+}
+
+_get_config_file_system() {
+ eval $1="${APPSH_DEFAULT_CONFIG-$APPSH_HOME/lib/default-config}"
+}
+
+_get_config_file_user() {
+ eval $1="$HOME/.appconfig"
+}
+
+_get_config_file_app() {
+ eval $1=".app/config"
+}
+
grep_path() {
local regex="$1"; shift
local path="$1"; shift