Consolidated TODOTXT_VERBOSE tests.
This commit is contained in:
52
todo.sh
52
todo.sh
@@ -618,8 +618,10 @@ case $action in
|
|||||||
input="$now $input"
|
input="$now $input"
|
||||||
fi
|
fi
|
||||||
echo "$input" >> "$TODO_FILE"
|
echo "$input" >> "$TODO_FILE"
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
TASKNUM=$(sed -n '$ =' "$TODO_FILE")
|
TASKNUM=$(sed -n '$ =' "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$input' added on line $TASKNUM."
|
echo "TODO: '$input' added on line $TASKNUM."
|
||||||
|
}
|
||||||
cleanup;;
|
cleanup;;
|
||||||
|
|
||||||
"addm")
|
"addm")
|
||||||
@@ -644,8 +646,10 @@ case $action in
|
|||||||
line="$now $line"
|
line="$now $line"
|
||||||
fi
|
fi
|
||||||
echo "$line" >> "$TODO_FILE"
|
echo "$line" >> "$TODO_FILE"
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
TASKNUM=$(sed -n '$ =' "$TODO_FILE")
|
TASKNUM=$(sed -n '$ =' "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$line' added on line $TASKNUM."
|
echo "TODO: '$line' added on line $TASKNUM."
|
||||||
|
}
|
||||||
done
|
done
|
||||||
IFS=$SAVEIFS
|
IFS=$SAVEIFS
|
||||||
cleanup;;
|
cleanup;;
|
||||||
@@ -660,8 +664,10 @@ case $action in
|
|||||||
|
|
||||||
if [ -f "$dest" ]; then
|
if [ -f "$dest" ]; then
|
||||||
echo "$input" >> "$dest"
|
echo "$input" >> "$dest"
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
TASKNUM=$(sed -n '$ =' "$dest")
|
TASKNUM=$(sed -n '$ =' "$dest")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$input' added to $dest on line $TASKNUM."
|
echo "TODO: '$input' added to $dest on line $TASKNUM."
|
||||||
|
}
|
||||||
else
|
else
|
||||||
echo "TODO: Destination file $dest does not exist."
|
echo "TODO: Destination file $dest does not exist."
|
||||||
fi
|
fi
|
||||||
@@ -684,8 +690,10 @@ case $action in
|
|||||||
cleaninput $input
|
cleaninput $input
|
||||||
|
|
||||||
if sed -i.bak $item" s|^.*|& $input|" "$TODO_FILE"; then
|
if sed -i.bak $item" s|^.*|& $input|" "$TODO_FILE"; then
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
echo "$item: $newtodo"
|
||||||
|
}
|
||||||
else
|
else
|
||||||
echo "TODO: Error appending task $item."
|
echo "TODO: Error appending task $item."
|
||||||
fi
|
fi
|
||||||
@@ -746,9 +754,11 @@ case $action in
|
|||||||
if [ "$?" -eq 0 ]; then
|
if [ "$?" -eq 0 ]; then
|
||||||
#it's all good, continue
|
#it's all good, continue
|
||||||
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "`echo "$item: $NEWTODO"`"
|
echo "`echo "$item: $NEWTODO"`"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item deprioritized."
|
echo "TODO: $item deprioritized."
|
||||||
|
}
|
||||||
cleanup
|
cleanup
|
||||||
else
|
else
|
||||||
die "$errmsg"
|
die "$errmsg"
|
||||||
@@ -774,9 +784,11 @@ case $action in
|
|||||||
# remove priority once item is done
|
# remove priority once item is done
|
||||||
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
|
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
|
||||||
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
|
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
echo "$item: $newtodo"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item marked as done."
|
echo "TODO: $item marked as done."
|
||||||
|
}
|
||||||
else
|
else
|
||||||
echo "$item is already marked done"
|
echo "$item is already marked done"
|
||||||
fi
|
fi
|
||||||
@@ -920,16 +932,20 @@ case $action in
|
|||||||
# If priority isn't set prepend
|
# If priority isn't set prepend
|
||||||
if [ -z $priority ]; then
|
if [ -z $priority ]; then
|
||||||
if sed -i.bak $item" s|^.*|$input &|" "$TODO_FILE"; then
|
if sed -i.bak $item" s|^.*|$input &|" "$TODO_FILE"; then
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
echo "$item: $newtodo"
|
||||||
|
}
|
||||||
else
|
else
|
||||||
echo "TODO: Error prepending task $item."
|
echo "TODO: Error prepending task $item."
|
||||||
fi
|
fi
|
||||||
# If priority is set, remove priority, prepend and add back priority
|
# If priority is set, remove priority, prepend and add back priority
|
||||||
else
|
else
|
||||||
if sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1 &|" "$TODO_FILE"; then
|
if sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1 &|" "$TODO_FILE"; then
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
echo "$item: $newtodo"
|
||||||
|
}
|
||||||
else
|
else
|
||||||
echo "TODO: Error prepending task $item."
|
echo "TODO: Error prepending task $item."
|
||||||
fi
|
fi
|
||||||
@@ -952,9 +968,11 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
if [ "$?" -eq 0 ]; then
|
if [ "$?" -eq 0 ]; then
|
||||||
#it's all good, continue
|
#it's all good, continue
|
||||||
sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE"
|
sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE"
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "`echo "$item: $NEWTODO"`"
|
echo "`echo "$item: $NEWTODO"`"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item prioritized ($newpri)."
|
echo "TODO: $item prioritized ($newpri)."
|
||||||
|
}
|
||||||
cleanup
|
cleanup
|
||||||
else
|
else
|
||||||
die "$errmsg"
|
die "$errmsg"
|
||||||
@@ -989,10 +1007,12 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
else
|
else
|
||||||
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1|" "$TODO_FILE"
|
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1|" "$TODO_FILE"
|
||||||
fi
|
fi
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $todo"
|
NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "replaced with"
|
echo "$item: $todo"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $NEWTODO"
|
echo "replaced with"
|
||||||
|
echo "$item: $NEWTODO"
|
||||||
|
}
|
||||||
cleanup;;
|
cleanup;;
|
||||||
|
|
||||||
"report" )
|
"report" )
|
||||||
|
|||||||
Reference in New Issue
Block a user