Skip to content

Commit

Permalink
Minimal config file / default filenames (todo.txt, done.txt, report.t…
Browse files Browse the repository at this point in the history
…xt) (todotxt#289)

* Set default files name

* Add test for minimal config file
  • Loading branch information
85 authored and wwalker committed Sep 19, 2021
1 parent ad21592 commit 15ae868
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/t0000-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,18 @@ test_expect_success 'config file (env variable)' '
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
4 changes: 4 additions & 0 deletions todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
|| 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\")."

[ -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 "$DONE_FILE" ] || [ -c "$DONE_FILE" ] || > "$DONE_FILE"
[ -f "$REPORT_FILE" ] || [ -c "$REPORT_FILE" ] || > "$REPORT_FILE"
Expand Down

0 comments on commit 15ae868

Please # to comment.