Priority is lost when adding via mit
Closed this issue · 1 comments
kodermike commented
Rule 1 of the todo-txt format: if Priority exists, it always appears first [https://github.com/ginatrapani/todo.txt-cli/wiki/the-todo.txt-format]. This is true when displaying via mit, but adding with mit treats priority as just part of the text blob, effectively losing priority and making priority no longer appearing first. The following diff (done horribly, but hey, it works :) ) will preserve priority when adding with mit enabled. FWIW, I am using the -t and -n options when using todo-cli.
--- mit 2015-12-30 12:59:26.363427384 -0800
+++ mit.new 2015-12-30 13:30:15.324974627 -0800
@@ -374,22 +374,31 @@ done
MITDATE=`echo $1 | tr [A-Z] [a-z]`
shift
MITTASK=$@
+ PRIORITYCHECK=`echo $MITTASK|awk '{print $1}'`
+ PRIORITIES='[A-Z]'
+ if [[ $PRIORITYCHECK =~ "("$PRIORITIES")" ]]; then
+ MITPRIORITY="$PRIORITYCHECK "
+ MITTASK=`echo $MITTASK | sed -e "s/$PRIORITYCHECK//"`
+ else
+ MITPRIORITY=""
+ fi
+
TODAY=`date +%u`
case $MITDATE in
today )
- NEWMIT="{`date +%Y.%m.%d`} $MITTASK"
+ NEWMIT="$MITPRIORITY{`date +%Y.%m.%d`} $MITTASK"
;;
tomorrow )
parseDAY 1d
- NEWMIT="{$MITDATE} $MITTASK"
+ NEWMIT="$MITPRIORITY{$MITDATE} $MITTASK"
;;
monday|mon|tuesday|tue|wednesday|wed|thursday|thu|friday|fri|saturday|sat|sunday|sun )
parseDAY $MITDATE
- NEWMIT="{$MITDATE} $MITTASK"
+ NEWMIT="$MITPRIORITY{$MITDATE} $MITTASK"
;;
[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9] )
- NEWMIT="{$MITDATE} $MITTASK"
+ NEWMIT="$MITPRIORITY{$MITDATE} $MITTASK"
;;
* )
error "invalid date"
codybuell commented
A little bit late in getting back to you but submit a pull request, include updated usage, and I'll add it in.