add optional timestamp when adding card; filter out more garbage input

This commit is contained in:
Yargo 2021-05-07 14:47:59 +02:00
parent b37bcf455f
commit fdf854885a
1 changed files with 18 additions and 3 deletions

View File

@ -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