Aligned implementations of verbose output.
Replaced multi-line [ ] && { ... } with if-then.
This commit is contained in:
28
todo.sh
28
todo.sh
@@ -280,8 +280,9 @@ archive()
|
|||||||
sed -i.bak '/^x /d' "$TODO_FILE"
|
sed -i.bak '/^x /d' "$TODO_FILE"
|
||||||
cp "$TODO_FILE" "$TMP_FILE"
|
cp "$TODO_FILE" "$TMP_FILE"
|
||||||
sed -n 'G; s/\n/&&/; /^\([ ~-]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE"
|
sed -n 'G; s/\n/&&/; /^\([ ~-]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE"
|
||||||
#[[ $TODOTXT_VERBOSE -gt 0 ]] && echo "TODO: Duplicate tasks have been removed."
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $TODO_FILE archived."
|
echo "TODO: $TODO_FILE archived."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceOrPrepend()
|
replaceOrPrepend()
|
||||||
@@ -542,13 +543,13 @@ _addto() {
|
|||||||
input="$now $input"
|
input="$now $input"
|
||||||
fi
|
fi
|
||||||
echo "$input" >> "$file"
|
echo "$input" >> "$file"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
TASKNUM=$(sed -n '$ =' "$file")
|
TASKNUM=$(sed -n '$ =' "$file")
|
||||||
BASE=$(basename "$file")
|
BASE=$(basename "$file")
|
||||||
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
|
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
|
||||||
echo "$TASKNUM: $input"
|
echo "$TASKNUM: $input"
|
||||||
echo "${PREFIX}: $TASKNUM added."
|
echo "${PREFIX}: $TASKNUM added."
|
||||||
}
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_list() {
|
_list() {
|
||||||
@@ -658,8 +659,7 @@ _list() {
|
|||||||
echo "--"
|
echo "--"
|
||||||
echo "${PREFIX}: ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown"
|
echo "${PREFIX}: ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown"
|
||||||
fi
|
fi
|
||||||
if [ $TODOTXT_VERBOSE -gt 1 ]
|
if [ $TODOTXT_VERBOSE -gt 1 ]; then
|
||||||
then
|
|
||||||
echo "TODO DEBUG: Filter Command was: ${filter_command:-cat}"
|
echo "TODO DEBUG: Filter Command was: ${filter_command:-cat}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -759,10 +759,10 @@ case $action in
|
|||||||
cleaninput $input
|
cleaninput $input
|
||||||
|
|
||||||
if sed -i.bak $item" s|^.*|&${appendspace}${input}|" "$TODO_FILE"; then
|
if sed -i.bak $item" s|^.*|&${appendspace}${input}|" "$TODO_FILE"; then
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item: $newtodo"
|
echo "$item: $newtodo"
|
||||||
}
|
fi
|
||||||
else
|
else
|
||||||
echo "TODO: Error appending task $item."
|
echo "TODO: Error appending task $item."
|
||||||
fi
|
fi
|
||||||
@@ -840,11 +840,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 ] && {
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item: $NEWTODO"
|
echo "$item: $NEWTODO"
|
||||||
echo "TODO: $item deprioritized."
|
echo "TODO: $item deprioritized."
|
||||||
}
|
fi
|
||||||
else
|
else
|
||||||
die "$errmsg"
|
die "$errmsg"
|
||||||
fi
|
fi
|
||||||
@@ -872,11 +872,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 ] && {
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item: $newtodo"
|
echo "$item: $newtodo"
|
||||||
echo "TODO: $item marked as done."
|
echo "TODO: $item marked as done."
|
||||||
}
|
fi
|
||||||
else
|
else
|
||||||
echo "$item is already marked done"
|
echo "$item is already marked done"
|
||||||
fi
|
fi
|
||||||
@@ -1008,11 +1008,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 ] && {
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item: $NEWTODO"
|
echo "$item: $NEWTODO"
|
||||||
echo "TODO: $item prioritized ($newpri)."
|
echo "TODO: $item prioritized ($newpri)."
|
||||||
}
|
fi
|
||||||
else
|
else
|
||||||
die "$errmsg"
|
die "$errmsg"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user