diff options
-rwxr-xr-x | bin/ak-settings | 5 | ||||
-rwxr-xr-x | lib/_ak_settings | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/bin/ak-settings b/bin/ak-settings index e096ff4..7fe1ee2 100755 --- a/bin/ak-settings +++ b/bin/ak-settings @@ -6,6 +6,11 @@ ## ## -h, --help Prints this help message ## +## -g, --get [key] Gets all the settings or, in case key is set, +## returns only the key-value specified +## +## -s, --set <key> <value> Sets the settings.key to value +## fullprogrampath="$(realpath $0)" PROGRAM=$(basename $0) descriptionString="Settings helper program" diff --git a/lib/_ak_settings b/lib/_ak_settings index ce0f9c4..500b34f 100755 --- a/lib/_ak_settings +++ b/lib/_ak_settings @@ -32,6 +32,11 @@ _ak_settings_get(){ _ak_log_error "Names containing symbols are not allowed" exit 1 fi + if [ ! -f $AK_SETTINGS/$subset/$label ] + then + _ak_log_error "Key: $subset.$label was not found" + exit 1 + fi cat $AK_SETTINGS/$subset/$label else cd $AK_SETTINGS @@ -77,6 +82,10 @@ _ak_settings_set(){ _ak_log_error "Names containing symbols are not allowed" exit 1 fi + if [ -f $AK_SETTINGS/$subset/$label ] + then + _ak_log_warning "Overwritting $subset.$label:$(cat $AK_SETTINGS/$subset/$label) with $2" + fi printf '%s' "$2" > $AK_SETTINGS/$subset/$label else _ak_log_error "No value provided for $1" |