Allow the use of global config file
If not found elsewhere, look for the config file in /etc/todo/config. `make install` installs a global config file, setting TODO_DIR=~/.todo. todo.sh creates TODO_DIR if it doesn't exist.
This commit is contained in:
@@ -8,6 +8,10 @@ to find it somewhere else.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
|
||||
# Override default global config file
|
||||
export TODOTXT_GLOBAL_CFG_FILE=global.cfg
|
||||
|
||||
# Remove the pre-created todo.cfg to test behavior in its absence
|
||||
rm -f todo.cfg
|
||||
echo "Fatal Error: Cannot read configuration file $HOME/.todo/config" > expect
|
||||
@@ -55,6 +59,14 @@ test_expect_success 'config file (default location 3)' '
|
||||
rm -f .todo.cfg
|
||||
'
|
||||
|
||||
rm -f used_config
|
||||
test_expect_success 'config file (global config file)' '
|
||||
cp test.cfg "$TODOTXT_GLOBAL_CFG_FILE"
|
||||
todo.sh > output;
|
||||
test_cmp expect output && test -f used_config &&
|
||||
rm -f "$TODOTXT_GLOBAL_CFG_FILE"
|
||||
'
|
||||
|
||||
rm -f used_config
|
||||
test_expect_success 'config file (command line)' '
|
||||
todo.sh -d test.cfg > output;
|
||||
|
||||
@@ -45,6 +45,9 @@ mv todo.cfg custom.cfg
|
||||
mv .todo.actions.d custom.actions
|
||||
echo 'export TODO_ACTIONS_DIR=$HOME/custom.actions' >> custom.cfg
|
||||
|
||||
# Avoid the use of global config file, if it exists
|
||||
export TODOTXT_GLOBAL_CFG_FILE=global.cfg
|
||||
|
||||
test_todo_session '-h and fatal error without config' <<EOF
|
||||
>>> todo.sh -h | sed '/^ \\{0,2\\}[A-Z]/!d'
|
||||
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
|
||||
|
||||
Reference in New Issue
Block a user