Merge branch 'mivok/master'

This commit is contained in:
Gina Trapani
2009-08-26 16:21:14 -07:00
2 changed files with 34 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ to find it somewhere else.
# Remove the pre-created todo.cfg to test behavior in its absence # Remove the pre-created todo.cfg to test behavior in its absence
rm -f todo.cfg rm -f todo.cfg
echo "Fatal error: Cannot read configuration file $HOME/todo.cfg" > expect echo "Fatal error: Cannot read configuration file $HOME/.todo/config" > expect
test_expect_success 'no config file' ' test_expect_success 'no config file' '
todo.sh > output 2>&1 || test_cmp expect output todo.sh > output 2>&1 || test_cmp expect output
' '
@@ -32,6 +32,15 @@ EOF
rm -f used_config rm -f used_config
test_expect_success 'config file (default location 1)' ' test_expect_success 'config file (default location 1)' '
mkdir .todo
cp test.cfg .todo/config
todo.sh > output;
test_cmp expect output && test -f used_config &&
rm -rf .todo
'
rm -f used_config
test_expect_success 'config file (default location 2)' '
cp test.cfg todo.cfg cp test.cfg todo.cfg
todo.sh > output; todo.sh > output;
test_cmp expect output && test -f used_config && test_cmp expect output && test -f used_config &&
@@ -39,7 +48,7 @@ test_expect_success 'config file (default location 1)' '
' '
rm -f used_config rm -f used_config
test_expect_success 'config file (default location 2)' ' test_expect_success 'config file (default location 3)' '
cp test.cfg .todo.cfg cp test.cfg .todo.cfg
todo.sh > output; todo.sh > output;
test_cmp expect output && test -f used_config && test_cmp expect output && test -f used_config &&

28
todo.sh
View File

@@ -1,7 +1,7 @@
#! /bin/bash #! /bin/bash
# NOTE: Todo.sh requires the todo.cfg configuration file to run. # NOTE: Todo.sh requires the .todo/config configuration file to run.
# Place the todo.cfg file in your home directory or use the -d option for a custom location. # Place the .todo/config file in your home directory or use the -d option for a custom location.
[ -f VERSION-FILE ] && . VERSION-FILE || VERSION="@DEV_VERSION@" [ -f VERSION-FILE ] && . VERSION-FILE || VERSION="@DEV_VERSION@"
version() { sed -e 's/^ //' <<EndVersion version() { sed -e 's/^ //' <<EndVersion
@@ -172,7 +172,7 @@ help()
Hide project names in list output. Use twice to show project Hide project names in list output. Use twice to show project
names (default). names (default).
-d CONFIG_FILE -d CONFIG_FILE
Use a configuration file other than the default ~/todo.cfg Use a configuration file other than the default ~/.todo/config
-f -f
Forces actions without confirmation or interactive input Forces actions without confirmation or interactive input
-h -h
@@ -341,7 +341,7 @@ shift $(($OPTIND - 1))
# defaults if not yet defined # defaults if not yet defined
TODOTXT_VERBOSE=${TODOTXT_VERBOSE:-1} TODOTXT_VERBOSE=${TODOTXT_VERBOSE:-1}
TODOTXT_PLAIN=${TODOTXT_PLAIN:-0} TODOTXT_PLAIN=${TODOTXT_PLAIN:-0}
TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-$HOME/todo.cfg} TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-$HOME/.todo/config}
TODOTXT_FORCE=${TODOTXT_FORCE:-0} TODOTXT_FORCE=${TODOTXT_FORCE:-0}
TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1} TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1}
TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1} TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1}
@@ -379,6 +379,15 @@ export PRI_B=$GREEN # color for B priority
export PRI_C=$LIGHT_BLUE # color for C priority export PRI_C=$LIGHT_BLUE # color for C priority
export PRI_X=$WHITE # color for rest of them export PRI_X=$WHITE # color for rest of them
[ -e "$TODOTXT_CFG_FILE" ] || {
CFG_FILE_ALT="$HOME/todo.cfg"
if [ -e "$CFG_FILE_ALT" ]
then
TODOTXT_CFG_FILE="$CFG_FILE_ALT"
fi
}
[ -e "$TODOTXT_CFG_FILE" ] || { [ -e "$TODOTXT_CFG_FILE" ] || {
CFG_FILE_ALT="$HOME/.todo.cfg" CFG_FILE_ALT="$HOME/.todo.cfg"
@@ -390,10 +399,19 @@ export PRI_X=$WHITE # color for rest of them
if [ -z "$TODO_ACTIONS_DIR" -o ! -d "$TODO_ACTIONS_DIR" ] if [ -z "$TODO_ACTIONS_DIR" -o ! -d "$TODO_ACTIONS_DIR" ]
then then
TODO_ACTIONS_DIR="$HOME/.todo.actions.d" TODO_ACTIONS_DIR="$HOME/.todo/actions"
export TODO_ACTIONS_DIR export TODO_ACTIONS_DIR
fi fi
[ -d "$TODO_ACTIONS_DIR" ] || {
TODO_ACTIONS_DIR_ALT="$HOME/.todo.actions.d"
if [ -d "$TODO_ACTIONS_DIR_ALT" ]
then
TODO_ACTIONS_DIR="$TODO_ACTIONS_DIR_ALT"
fi
}
# === SANITY CHECKS (thanks Karl!) === # === SANITY CHECKS (thanks Karl!) ===
[ -r "$TODOTXT_CFG_FILE" ] || die "Fatal error: Cannot read configuration file $TODOTXT_CFG_FILE" [ -r "$TODOTXT_CFG_FILE" ] || die "Fatal error: Cannot read configuration file $TODOTXT_CFG_FILE"