]> gitweb.fluxo.info Git - scripts.git/commitdiff
Feat: collector: count action
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 27 Jul 2024 20:54:52 +0000 (17:54 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 27 Jul 2024 20:54:52 +0000 (17:54 -0300)
collector

index 570d13c975e3f170f880290bf6a4eb03a6e26acf..387cb02abe325321027ea4bfcdb0277b6583f775 100755 (executable)
--- a/collector
+++ b/collector
@@ -9,6 +9,7 @@
 # Parameters
 BASENAME="`basename $0`"
 ACTION="$1"
+COLLECTOR_NAME="`echo $COLLECTOR_FILE | sed -e "s|$HOME|~|"`"
 
 # Check
 if [ -z "$COLLECTOR_FILE" ]; then
@@ -30,13 +31,17 @@ elif [ "$ACTION" == "add" ]; then
   echo "* $*" >> "$COLLECTOR_FILE"
 elif [ "$ACTION" == "list" ]; then
   if grep -q -e "^ *\* " "$COLLECTOR_FILE"; then
-    COLLECTOR_NAME="`echo $COLLECTOR_FILE | sed -e "s|$HOME|~|"`"
-
     echo "Collected items at $COLLECTOR_NAME:"
     echo ""
     grep -e "^ *\* " "$COLLECTOR_FILE"
     echo ""
   fi
+elif [ "$ACTION" == "count" ]; then
+  if grep -q -e "^ *\* " "$COLLECTOR_FILE"; then
+    COUNT="`grep -e "^ *\* " "$COLLECTOR_FILE" | wc -l`"
+    echo "$COUNT collected items at $COLLECTOR_NAME"
+    echo ""
+  fi
 elif [ "$ACTION" == "edit" ]; then
   if [ ! -z "$EDITOR" ]; then
     $EDITOR "$COLLECTOR_FILE"