Minimal config file / default filenames (todo.txt, done.txt, report.txt) (#289)

* Set default files name

* Add test for minimal config file
This commit is contained in:
85
2020-03-30 02:33:16 +07:00
committed by GitHub
parent c6d290b5fb
commit 3d308a6f79
2 changed files with 18 additions and 0 deletions

View File

@@ -79,4 +79,18 @@ test_expect_success 'config file (env variable)' '
test_cmp expect output && test -f used_config test_cmp expect output && test -f used_config
' '
cat > minimal.cfg << EOF
export TODO_DIR=.
touch used_config
EOF
rm -f used_config
test_expect_success 'config file (minimal)' '
mkdir .todo
cp minimal.cfg .todo/config
todo.sh > output;
test_cmp expect output && test -f used_config &&
rm -rf .todo
'
test_done test_done

View File

@@ -785,6 +785,10 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
|| echo "$TODOTXT_PRIORITY_ON_ADD" | grep -q "^[A-Z]$" \ || echo "$TODOTXT_PRIORITY_ON_ADD" | grep -q "^[A-Z]$" \
|| die "TODOTXT_PRIORITY_ON_ADD should be a capital letter from A to Z (it is now \"$TODOTXT_PRIORITY_ON_ADD\")." || die "TODOTXT_PRIORITY_ON_ADD should be a capital letter from A to Z (it is now \"$TODOTXT_PRIORITY_ON_ADD\")."
[ -z "$TODO_FILE" ] && TODO_FILE="$TODO_DIR/todo.txt"
[ -z "$DONE_FILE" ] && DONE_FILE="$TODO_DIR/done.txt"
[ -z "$REPORT_FILE" ] && REPORT_FILE="$TODO_DIR/report.txt"
[ -f "$TODO_FILE" ] || [ -c "$TODO_FILE" ] || > "$TODO_FILE" [ -f "$TODO_FILE" ] || [ -c "$TODO_FILE" ] || > "$TODO_FILE"
[ -f "$DONE_FILE" ] || [ -c "$DONE_FILE" ] || > "$DONE_FILE" [ -f "$DONE_FILE" ] || [ -c "$DONE_FILE" ] || > "$DONE_FILE"
[ -f "$REPORT_FILE" ] || [ -c "$REPORT_FILE" ] || > "$REPORT_FILE" [ -f "$REPORT_FILE" ] || [ -c "$REPORT_FILE" ] || > "$REPORT_FILE"