Skip to content

Commit

Permalink
added option to disable final filter
Browse files Browse the repository at this point in the history
The option marker was chosen as "-x" here.
Alternatives might be "-X" or "-*".
  • Loading branch information
FND committed Aug 30, 2009
1 parent 266d9e1 commit 490f5d3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
29 changes: 28 additions & 1 deletion tests/t1300-ls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,34 @@ TODO: 3 of 3 tasks shown from $HOME/todo.txt
EOF

#
# check the p command line option
# check the x command line option
#
TEST_TODO3_=todo3.cfg
sed -e "s%^.*export TODOTXT_FINAL_FILTER=.*$%export TODOTXT_FINAL_FILTER=\"grep -v xxx\"%" "${TEST_TODO_}" > "${TEST_TODO3_}"

cat > todo.txt <<EOF
foo
bar xxx
baz
EOF

test_todo_session 'final filter suppression' <<EOF
>>> todo.sh -d "$TEST_TODO3_" ls
3 baz
1 foo
--
TODO: 2 of 3 tasks shown from $HOME/todo.txt
>>> todo.sh -d "$TEST_TODO3_" -x ls
2 bar xxx
3 baz
1 foo
--
TODO: 3 of 3 tasks shown from $HOME/todo.txt
EOF

#
# check the p command line option
#
cat > todo.txt <<EOF
(A) @con01 +prj01 -- Some project 01 task, pri A
Expand Down
10 changes: 9 additions & 1 deletion todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ help()
Extra verbose mode prints some debugging information
-V
Displays version, license and credits
-x
Disables TODOTXT_FINAL_FILTER
Environment variables:
Expand Down Expand Up @@ -256,7 +258,7 @@ archive()


# == PROCESS OPTIONS ==
while getopts ":fhpnatvV+@Pd:" Option
while getopts ":fhpnatvVx+@Pd:" Option
do
case $Option in
'@' )
Expand Down Expand Up @@ -334,6 +336,9 @@ do
V )
version
;;
x )
TODOTXT_DISABLE_FILTER=1
;;
esac
done
shift $(($OPTIND - 1))
Expand Down Expand Up @@ -497,6 +502,9 @@ _list() {

## Number the file, then run the filter command,
## then sort and mangle output some more
if [[ $TODOTXT_DISABLE_FILTER = 1 ]]; then
TODOTXT_FINAL_FILTER="cat"
fi
items=$(
sed = "$src" \
| sed "N; s/^/ /; s/ *\(.\{$PADDING,\}\)\n/\1 /" \
Expand Down

0 comments on commit 490f5d3

Please sign in to comment.