43 lines
1.1 KiB
Bash
Executable File
43 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
type agenda >/dev/null
|
|
|
|
if [ "${AGENDA_EXTENSION:-}" != "md" ]; then
|
|
exit
|
|
fi
|
|
|
|
# Capitalize the title.
|
|
echo "$AGENDA_NAME $AGENDA_DATE" | awk '{print "# "toupper(substr($0,0,1))tolower(substr($0,2))}'
|
|
echo
|
|
|
|
if [ -n "${AGENDA_IS_BACKLOG:-}" ]; then
|
|
exit
|
|
fi
|
|
|
|
# Carry over open tasks from the last agenda markdown file.
|
|
if [ -e "$AGENDA_LAST" ] && [ "${AGENDA_LAST#*.}" = "md" ]; then
|
|
while IFS= read -r REPLY; do
|
|
case ${state:-} in
|
|
"open_task")
|
|
case $REPLY in
|
|
"- [ ] "*|" "*)
|
|
# Append indented lines to open tasks.
|
|
echo "$REPLY"
|
|
;;
|
|
*)
|
|
unset state
|
|
;;
|
|
esac
|
|
;;
|
|
*)
|
|
case $REPLY in
|
|
"[ ] "*|"[@] "*|"[?] "*)
|
|
state="open_task"
|
|
echo "$REPLY"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
done < "$AGENDA_LAST"
|
|
fi
|