initial: first working draft, copied over from sandbox
This commit is contained in:
commit
c19679e50d
|
@ -0,0 +1,5 @@
|
|||
# clikan.sh : command line kanban
|
||||
|
||||
shell script to handle kanban file(s) in Markdown format
|
||||
|
||||
*WIP* ;-)
|
|
@ -0,0 +1,207 @@
|
|||
#!/bin/sh
|
||||
# clikan.sh -- CLI Kanban
|
||||
# 2017-06-20 Y.Bonetti
|
||||
|
||||
conf="${CLIKANCONF:-$HOME/.clikanconf}"
|
||||
defkanban="$HOME/mykanban.txt"
|
||||
editor="${CLIKANEDIT:-$VISUAL}"
|
||||
editor="${editor:-$EDITOR}"
|
||||
editor="${editor:-/bin/ed}"
|
||||
echo editor=$editor
|
||||
tmpf=$HOME/.clikan.tmp
|
||||
|
||||
if test ! -f "$conf"
|
||||
then echo generating default config file $conf
|
||||
cat <<EOT >"$conf"
|
||||
# automatically generated by $0 at `date`
|
||||
prompt ck>
|
||||
kanban $defkanban
|
||||
EOT
|
||||
echo initializing default kanban file $defkanban
|
||||
cat <<EOT >"$defkanban"
|
||||
# my kanban file
|
||||
* 12345 learn to use clikan
|
||||
- 23456 improve clikan
|
||||
EOT
|
||||
fi
|
||||
|
||||
# get lines beginning with a value, and remove that column
|
||||
# note SPC&TAB in patterns: make sure there is a SPC,
|
||||
# and that the value is complete
|
||||
getlines(){
|
||||
sed -e 's/$/ /' | grep "^$1[ ]" | { while read _ values
|
||||
# remove trailing added TAB
|
||||
do echo "${values% }"
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
# display selection, and put selection list in tempfile
|
||||
# input through stdin, with lines "key explanation", where "key" is stored
|
||||
# in tmpf together with index number, and "explanation" is displayed
|
||||
# (or "key", if "explanation" is empty)
|
||||
showselect(){
|
||||
local i
|
||||
: >$tmpf
|
||||
i=1
|
||||
while read j e
|
||||
do if test "$e" = ""
|
||||
then e=$j
|
||||
fi
|
||||
echo $i: $e
|
||||
echo "$i $j" >>$tmpf
|
||||
i=$(( $i+1 ))
|
||||
done
|
||||
}
|
||||
|
||||
# get input from selection (showselect must be called before)
|
||||
getselect(){
|
||||
if test "$1" != ""
|
||||
then echo "choice? (default: $1)" >&2
|
||||
else echo "choice?" >&2
|
||||
fi
|
||||
read i
|
||||
if test "$i" = ""
|
||||
then echo "$1"
|
||||
else getlines $i <$tmpf
|
||||
fi
|
||||
}
|
||||
|
||||
kbs="`getlines kanban <"$conf"`"
|
||||
currkan="`echo "$kbs" | head -n 1`"
|
||||
prompt=`getlines prompt <"$conf" | head -n 1`
|
||||
#echo conf=$conf
|
||||
#echo kbs=$kbs
|
||||
#echo currkan=$currkan
|
||||
|
||||
showprompt(){
|
||||
if test "$prompt" != ""
|
||||
then echo -n $prompt ''
|
||||
fi
|
||||
}
|
||||
|
||||
# display all 'something' cards
|
||||
showall(){
|
||||
local f
|
||||
case $1 in
|
||||
d*) f='*' ;;
|
||||
w*) f='-' ;;
|
||||
a*) f='+' ;;
|
||||
*) f='' ;;
|
||||
esac
|
||||
echo
|
||||
echo " $1"
|
||||
cat "$kbs" | getlines "$f" | showselect
|
||||
}
|
||||
|
||||
# get first complete card with pattern
|
||||
getfirst(){
|
||||
cat "$kbs" | grep "$1" | head -n 1
|
||||
}
|
||||
|
||||
# replace lines (in any kanban) containing some ed pattern
|
||||
# arg.1=pattern, remainder=new line contents
|
||||
repline(){
|
||||
local patt newl
|
||||
patt="$1"
|
||||
shift
|
||||
newl="$*"
|
||||
for ff in $kbs
|
||||
do cat <<EOC | ed "$ff" >/dev/null 2>&1
|
||||
%g/$patt/c\\
|
||||
$newl\\
|
||||
.
|
||||
w
|
||||
q
|
||||
EOC
|
||||
done
|
||||
}
|
||||
|
||||
showhelp(){ cat <<EOH
|
||||
$0 : command line kanban
|
||||
configuration file: $conf
|
||||
can be defined by env.var CLICKANCONF, contains lines with
|
||||
prompt PROMPT # displayed before every entry
|
||||
kanban FILENAME # defines a kanban file, may be given several times
|
||||
(note: keywords and arguments should be separated by TABs)
|
||||
for help about commands, just hit RETURN
|
||||
to show configuration, enter 'c'
|
||||
EOH
|
||||
read k
|
||||
case $k in
|
||||
c*) echo "configfile=$conf // CLIKANCONF=$CLIKANCONF"
|
||||
echo "configfile contents:"
|
||||
sed -e 's/^/ /' $conf
|
||||
;;
|
||||
*) cat <<EOH
|
||||
command keys:
|
||||
q: quit
|
||||
d/w/a: show 'doing/waiting(todo)/archive(done)' cards
|
||||
k: select target kanban for entry of new cards
|
||||
n: add new card to target kanban
|
||||
done N: archive card N as done
|
||||
wait N: put card N back to waiting/todo state
|
||||
do N: put card N into doing state
|
||||
ec: directly edit config file -- DANGER!
|
||||
ek: directly edit kanban file -- DANGER!
|
||||
EOH
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
echo this is $0
|
||||
showall doing
|
||||
showprompt
|
||||
|
||||
while read com coa1 coa2 coa3 coar
|
||||
do case $com in
|
||||
q*) break ;;
|
||||
d) showall doing ;;
|
||||
w) showall waiting/todo ;;
|
||||
a) showall archived/done ;;
|
||||
do|wait|done) if test "$coa1" = ""
|
||||
then echo "card number?"
|
||||
read coa1
|
||||
fi
|
||||
if test "$coa1" != ""
|
||||
then coa1=`getlines $coa1 <$tmpf`
|
||||
case $com in
|
||||
done) coa2='+' ;;
|
||||
wait) coa2='-' ;;
|
||||
*) coa2='*' ;;
|
||||
esac
|
||||
coa3=`getfirst "^.[ ] *$coa1" <$tmpf | sed -e "s/^./$coa2/"`
|
||||
#echo coa1=$coa1
|
||||
#echo coa2=$coa2
|
||||
#echo coa3=$coa3
|
||||
repline "^.[ ] *$coa1" "$coa3"
|
||||
fi
|
||||
showall doing
|
||||
;;
|
||||
k) echo "$kbs" | showselect
|
||||
currkan=`getselect $currkan`
|
||||
showall doing
|
||||
;;
|
||||
n) echo enter new card for target $currkan :
|
||||
read newc
|
||||
if test "$newc" != ""
|
||||
then uid=`date +%s`
|
||||
echo '-' $uid "$newc" >>$currkan
|
||||
fi
|
||||
showall doing
|
||||
;;
|
||||
ec) echo calling "$editor $conf" ...
|
||||
"$editor" "$conf"
|
||||
echo please quit and restart to reload config ;;
|
||||
ek) echo "$kbs" | showselect
|
||||
f=`getselect`
|
||||
echo calling "$editor $f" ...
|
||||
"$editor" "$f"
|
||||
echo welcome back ;;
|
||||
*) showhelp
|
||||
showall doing ;;
|
||||
esac
|
||||
showprompt
|
||||
done
|
||||
|
||||
#/bin/rm -f $tmpf
|
|
@ -0,0 +1,15 @@
|
|||
# clikan todo
|
||||
|
||||
_currently just for me (YB) and therefore in German_
|
||||
|
||||
- # Kommentare am Anfang ignoriert b erhaltn
|
||||
- ## Sektoren : eine/alle angezeigt, *alle Doing*
|
||||
+ Zeilen entspr Karten, Tab-getrennte Spalten; Spalte1= `-/*/+` Wait/Doing/Archive Flag, Spalte2= UID, Rest= Inhalt o `[]( UID-File )`
|
||||
+ Domaenen-Liste (Arbeitsverzeichnisse) Default o env-Variable
|
||||
+ UID-File: erste Zeile = Zeile aus Liste m # statt Flag, Folgezeilen=Inhalt; autom erzeugt i Karte 2 o pl Zeilen h
|
||||
+ Stdanzeige Doing, ein Bildshirm voll
|
||||
- Termine m Moegl fr Wiederholg/Ewig, g n Ablauf zrueck in Wait statt Archive ?
|
||||
+ Vershiebg Wait/Doing/Archive
|
||||
+ Neu hinzu in Wait der akt Domaene
|
||||
- heutige u morgige Termine in Doing uebernehmn
|
||||
- Terminanzeige, 1 Tag o Wo n best Datum?
|
Loading…
Reference in New Issue