Permalink
Browse files

ENH: TODOTXT_SOURCEVAR enables different source file for listproj.

  • Loading branch information...
1 parent 9e13dfd commit 46afb7f46ac1163b471e824934f7900e740d431c @inkarkat committed Feb 21, 2012
Showing with 27 additions and 2 deletions.
  1. +23 −0 tests/t1320-listproj.sh
  2. +4 −2 todo.sh
View
@@ -55,4 +55,27 @@ test_todo_session 'listproj embedded + test' <<EOF
+prj02
EOF
+cat > todo.txt <<EOF
++prj01 -- Some project 1 task
+EOF
+cat > done.txt <<EOF
+x 2012-02-21 +done01 -- Special project 1 done task
+x 2012-02-21 +done02 -- Some project 2 done task
+EOF
+test_todo_session 'listproj from done tasks' <<'EOF'
+>>> TODOTXT_SOURCEVAR=\$DONE_FILE todo.sh listproj
++done01
++done02
+EOF
+test_todo_session 'listproj from done tasks with filtering' <<'EOF'
+>>> TODOTXT_SOURCEVAR=\$DONE_FILE todo.sh listproj Special
++done01
+EOF
+test_todo_session 'listproj from combined open + done tasks' <<'EOF'
+>>> TODOTXT_SOURCEVAR='("$TODO_FILE" "$DONE_FILE")' todo.sh listproj
++done01
++done02
++prj01
+EOF
+
test_done
View
@@ -149,7 +149,7 @@ help()
TODOTXT_DEFAULT_ACTION="" run this when called with no arguments
TODOTXT_SORT_COMMAND="sort ..." customize list output
TODOTXT_FINAL_FILTER="sed ..." customize list after color, P@+ hiding
- TODOTXT_SOURCEVAR=\$DONE_FILE use another source for listcon
+ TODOTXT_SOURCEVAR=\$DONE_FILE use another source for listcon, listproj
EndVerboseHelp
@@ -1135,8 +1135,10 @@ case $action in
;;
"listproj" | "lsprj" )
+ FILE=$TODO_FILE
+ [ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR"
shift
- eval "$(filtercommand 'cat "$TODO_FILE"' '' "$@")" | grep -o '[^ ]*+[^ ]\+' | grep '^+' | sort -u
+ eval "$(filtercommand 'cat "${FILE[@]}"' '' "$@")" | grep -o '[^ ]*+[^ ]\+' | grep '^+' | sort -u
;;
"listpri" | "lsp" )

0 comments on commit 46afb7f

Please sign in to comment.