documentation

This commit is contained in:
James Tomasino 2019-03-21 18:39:12 -04:00
parent 9c7e2b4fb2
commit 23cf02ce91

15
todo
View File

@ -63,32 +63,32 @@ fi
eval set -- "${parsed}" eval set -- "${parsed}"
while true; do while true; do
case "$1" in case "$1" in
-h) -h) # help
show_help show_help
exit 0 exit 0
;; ;;
-v) -v) # version
printf "%s\\n" "$version" printf "%s\\n" "$version"
exit 0 exit 0
;; ;;
-e) -e) # edit TODO file
printf "Opening %s in %s\\n" "$TODOFILE" "${EDITOR:-nano}" printf "Opening %s in %s\\n" "$TODOFILE" "${EDITOR:-nano}"
${EDITOR:-nano} "${TODOFILE}" ${EDITOR:-nano} "${TODOFILE}"
exit 0 exit 0
;; ;;
-a) -a) # add TODO item
shift shift
message="$1" message="$1"
printf "%s\\n" "$message" >> "$TODOFILE" printf "%s\\n" "$message" >> "$TODOFILE"
exit 0 exit 0
;; ;;
-x) -x) # view archive
if [ -f "$TODOARCHIVEFILE" ] ; then if [ -f "$TODOARCHIVEFILE" ] ; then
cat "$TODOARCHIVEFILE" cat "$TODOARCHIVEFILE"
fi fi
exit 0 exit 0
;; ;;
-d) -d) # delete TODO item(s)
shift shift
if printf "%s" "$1" | grep -Eq '^[+-]?[0-9]+$'; then if printf "%s" "$1" | grep -Eq '^[+-]?[0-9]+$'; then
match=$(sed -n "${1}p" "$TODOFILE" 2> /dev/null) match=$(sed -n "${1}p" "$TODOFILE" 2> /dev/null)
@ -109,13 +109,14 @@ while true; do
shift shift
break break
;; ;;
*) *) # We shouldn't be able to get here. Error
exit 1 exit 1
;; ;;
esac esac
shift shift
done done
# When no arguments are passed, we default to showing the TODO file
if [ -f "$TODOFILE" ] ; then if [ -f "$TODOFILE" ] ; then
awk '{ print NR, "-", $0 }' "$TODOFILE" awk '{ print NR, "-", $0 }' "$TODOFILE"
fi fi