From 0d0942341220c5cd906013160aabe7500e22a49c Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 15 Jul 2008 23:38:30 +0200 Subject: [PATCH] Implemented `todo -L`, listing the hashes of all entries, or those on the given tags --- todo.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index 90b2830..5cc0fbd 100755 --- a/todo.sh +++ b/todo.sh @@ -24,6 +24,7 @@ todo_usage() Usage: $0 [options] [] ${cmd} [-t *] [] - new entry ${cmd} [-T|--tags] - list tags + ${cmd} [-L] [*] - list entry hashes EOT exit 1 @@ -44,7 +45,7 @@ todo_sane_tags() trap ':' INT -options=$( getopt -o "t:T" -l "tags" -- "$@" ) +options=$( getopt -o "t:TL" -l "tags" -- "$@" ) if [ $? -ne 0 ]; then todo_usage fi @@ -59,6 +60,8 @@ while [ $# -gt 0 ]; do case "$1" in -T|--tags) MODE=tags ;; + -L) + MODE=list_raw ;; -t) TAGS="$TAGS $2"; shift ;; @@ -124,7 +127,21 @@ todo_tags() ls -1d "$TODODIR"/* | sed -e "s,^$TODODIR/,," | grep -v '^entries$' } +todo_list_raw() +{ + local tags="$(todo_sane_tags $TAGS $*)" + local tag= + if [ -n "$tags" ]; then + for tag in $tags; do + ls -1 "$TODODIR/$tag"/* + done + else + ls -1 "$TODODIR/entries"/*/* + fi 2> /dev/null | sed -e 's,.*/,,' | sort -u +} case "$MODE" in - new) todo_new "$@" ;; + new) todo_new "$*" ;; tags) todo_tags ;; + + list_raw) todo_list_raw "$*" ;; esac -- 2.11.4.GIT