feat!: add builtin templates
WIP: document, check for breaking changes, decide on version, etc.
This commit is contained in:
6
templates/default
Executable file
6
templates/default
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
type agenda >/dev/null
|
||||
|
||||
# Capitalize the title.
|
||||
echo "$AGENDA_NAME $AGENDA_DATE" | awk '{print toupper(substr($0,0,1))tolower(substr($0,2))}'
|
||||
42
templates/md
Executable file
42
templates/md
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/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
|
||||
56
templates/xit
Executable file
56
templates/xit
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
type agenda >/dev/null
|
||||
|
||||
if [ "${AGENDA_EXTENSION:-}" != "xit" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Capitalize the title.
|
||||
echo "$AGENDA_NAME $AGENDA_DATE" | awk '{print toupper(substr($0,0,1))tolower(substr($0,2))}'
|
||||
|
||||
if [ -n "${AGENDA_IS_BACKLOG:-}" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Carry over open tasks from the last agenda xit file.
|
||||
if [ -e "$AGENDA_LAST" ] && [ "${AGENDA_LAST#*.}" = "xit" ]; then
|
||||
line=0
|
||||
while IFS= read -r REPLY; do
|
||||
line=$(( line + 1 ))
|
||||
case ${state:-} in
|
||||
"open_task")
|
||||
case $REPLY in
|
||||
"[ ] "*|"[@] "*|"[?] "*|" "*)
|
||||
# Append indented lines to open tasks.
|
||||
echo "$REPLY"
|
||||
;;
|
||||
*)
|
||||
unset state
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
case $REPLY in
|
||||
"[ ] "*|"[@] "*|"[?] "*)
|
||||
# Carry over group heading with open tasks.
|
||||
if [ -n "${header:-}" ]; then
|
||||
echo
|
||||
echo "$header"
|
||||
unset header
|
||||
fi
|
||||
state="open_task"
|
||||
echo "$REPLY"
|
||||
;;
|
||||
[a-z]*|[A-Z]*)
|
||||
# Skip the first heading (assumed to be the generated
|
||||
# title of the agenda note).
|
||||
if [ $line -gt 1 ]; then
|
||||
header=$REPLY
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done < "$AGENDA_LAST"
|
||||
fi
|
||||
Reference in New Issue
Block a user