diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-10-08 09:29:40 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-10-08 09:29:40 -0300 |
commit | c516526728430aab6af7d8fe2200219b754023cd (patch) | |
tree | 7c4d4b33810443f71736f95de6dda8f9ccd2e23a | |
parent | 1e62399a984f861e5c09105aeae93add96a4b313 (diff) | |
download | scripts-c516526728430aab6af7d8fe2200219b754023cd.tar.gz scripts-c516526728430aab6af7d8fe2200219b754023cd.tar.bz2 |
Filter support into TODO script
-rwxr-xr-x | todo | 31 |
1 files changed, 23 insertions, 8 deletions
@@ -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 <file>" |