From 4ec2ccefc35e250650f702e08b1c916d112761a8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 27 Jul 2024 17:54:52 -0300 Subject: Feat: collector: count action --- collector | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'collector') diff --git a/collector b/collector index 570d13c..387cb02 100755 --- 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" -- cgit v1.2.3