Add support for the `listall' subcommand - justdoit - Simpler (but with not all the features) reimplementation todo.txt CLI
(HTM) hg clone https://bitbucket.org/iamleot/justdoit
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset 7157f6477bfa22cbe6f85d88ac36aaf88564d5f6
(DIR) parent 64cfda888a1f1feac9df932d90383f7b410f3cf7
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sat, 18 Aug 2018 13:38:21
Add support for the `listall' subcommand
Add a listall subcommand that will print both todo.txt and done.txt files.
Also adjust prettify() in order to gsub() just description, make it aware of
possible completion entries and count via an `n' variable that is incremented
only for non-done items.
Diffstat:
t.sh | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
---
diff -r 64cfda888a1f -r 7157f6477bfa t.sh
--- a/t.sh Sat Aug 18 12:32:09 2018 +0200
+++ b/t.sh Sat Aug 18 13:38:21 2018 +0200
@@ -43,7 +43,7 @@
usage()
{
- echo "usage: t add|done|edit|help|list"
+ echo "usage: t add|done|edit|help|list|listall"
exit 1
}
@@ -94,6 +94,19 @@
#
+# List all entries, show the contents of todo.txt and done.txt file
+#
+listall()
+{
+ tfile=$1
+ dfile=$2
+ search=$3
+
+ cat "${dfile}" "${tfile}" | prettify | grep -F -- "${search}"
+}
+
+
+#
# Prettify the output of a todo.txt
#
prettify()
@@ -168,9 +181,14 @@
{
# bold all the tags
- gsub(/@[^ ]+/, "\033[1m&\033[0m")
+ gsub(/@[^ ]+/, "\033[1m&\033[0m", description)
- printf("%12s %s\n", underline(NR), description)
+ if (completion) {
+ printf("%12s %s\n", underline(completion), description)
+ } else {
+ n++
+ printf("%12s %s\n", underline(n), description)
+ }
}
'
}
@@ -202,6 +220,10 @@
search=$2
list "${todo_file}" "${search}"
;;
+ la|lsa|listall)
+ search=$2
+ listall "${todo_file}" "${done_file}" "${search}"
+ ;;
*)
usage
;;