From c516526728430aab6af7d8fe2200219b754023cd Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 8 Oct 2017 09:29:40 -0300 Subject: Filter support into TODO script --- todo | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'todo') diff --git a/todo b/todo index a4589c7..0543ca1 100755 --- a/todo +++ b/todo @@ -36,20 +36,33 @@ function todo_find { } function todo_list { + local status="$1" + todo_find | while read todo; do if [ "$todo" != "$NAME" ]; then - path="`echo $todo | sed -e "s|^$HOME|~|"`" - delim="===`echo $path | sed -e 's|.|=|g'`" - echo "" - echo In $path - echo $delim - echo "" - grep -e '*' -e '-' $todo + if [ ! -z "$status" ] && ! grep -q "\($status\)" $todo; then + continue + fi + + path="`echo $todo | sed -e "s|^$HOME|~|"`" + delim="===`echo $path | sed -e 's|.|=|g'`" + #echo "" + echo In $path + echo $delim + echo "" + + if [ ! -z "$status" ]; then + grep -e '*' -e '-' $todo | grep "\($status\)" + else + grep -e '*' -e '-' $todo + fi + + echo "" fi done } -if [ "$OPTION" == "list" ]; then +if [ "$OPTION" == "find" ]; then todo_find | grep -v -e "^$NAME$" | sed -e "s|^$HOME|~|" elif [ "$OPTION" == "count" ]; then todo_find | grep -v $NAME | wc -l @@ -61,6 +74,8 @@ elif [ "$OPTION" == "show" ]; then # Check also for FIXMEs fixmes $2 fi +elif [ "$OPTION" == "list" ]; then + todo_list $2 elif [ "$OPTION" == "help" ]; then echo "usage: $BASENAME [list|count]" echo " $BASENAME show " -- cgit v1.2.3