]> gitweb.fluxo.info Git - scripts.git/commitdiff
Filter support into TODO script
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 8 Oct 2017 12:29:40 +0000 (09:29 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 8 Oct 2017 12:29:40 +0000 (09:29 -0300)
todo

diff --git a/todo b/todo
index a4589c76ced2ac13152495d9b4c8fb69652a1ffb..0543ca155aa646d123e3587ca648b8ee35aa23f5 100755 (executable)
--- 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 <file>"