From fdf854885a42c21a90e8c5ac94191c75b6d3f22c Mon Sep 17 00:00:00 2001 From: Yargo Date: Fri, 7 May 2021 14:47:59 +0200 Subject: [PATCH] add optional timestamp when adding card; filter out more garbage input --- clikan.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/clikan.sh b/clikan.sh index 5fe1975..c498c8a 100755 --- a/clikan.sh +++ b/clikan.sh @@ -1,6 +1,6 @@ #!/bin/sh # clikan.sh -- CLI Kanban -ver='2021-02-25/HB9KNS' +ver='2021-05-07/HB9KNS' conf="${CLIKANCONF:-$HOME/.clikanconf}" defkanban="$HOME/clikanban.md" @@ -33,6 +33,9 @@ maxshow 23 # sortdir defines order of non-calendar kanban cards # and can be one of up, down or none (default) sortdir up +# if newdate is 1, yes or true (actually, begins with'[1tTyY]'), +# then the current date will be appended to new cards/entries +newdate true # kanban defines a kanban file, may be given several times # kanban /some/path/to/jobkanban.txt # kanban /another/path/to/privatekanban.md @@ -99,6 +102,11 @@ maxshow=`getlines maxshow <"$conf" | head -n 1` maxshow=${maxshow:-22} sortdir=`getlines sortdir <"$conf" | head -n 1` sortdir=${sortdir:-none} +nd=`getlines newdate <"$conf" | head -n 1` +case $nd in + 1|[yY]*|[tT]*) newdate=true ;; + *) newdate=false ;; +esac showprompt(){ if test "$prompt" != "" @@ -216,7 +224,10 @@ do|wait|done) if test "$coa1" = "" then echo "card number?" read coa1 fi - coar=`echo "$coa1 $coa2 $coa3 $coar" | sed -e 's/ *$/ /'` + coar=`echo "$coa1 $coa2 $coa3 $coar" | tr -cd ' 0-9' | sed -e 's/ *$/ /'` + if test "$coar" = " " + then coar='' + fi while test "$coar" != "" do coa1=`getlines ${coar%% *} <$self` @@ -245,8 +256,12 @@ n) newc=`echo "$coa1 $coa2 $coa3 $coar" | sed -e 's/ *$//'` read newc else echo adding card for target $currkan fi + if test $newdate = true + then stamp=`date '+ // %y-%m-%d'` + else stamp='' + fi if test "$newc" != "" - then echo '*' "$newc" >>$currkan + then echo '*' "$newc$stamp" >>$currkan else echo no content found, nothing added fi showall doing