24 lines
631 B
Bash
Executable File
24 lines
631 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# description: Add one or more tasks to the session plan checklist
|
|
# Args: <task> [task2 task3 ...]
|
|
|
|
[ -z "$*" ] && echo "usage: task_add <task> [task2 ...]" >&2 && exit 1
|
|
[ -z "$OLLIE_SESSION_ID" ] && echo "error: OLLIE_SESSION_ID not set" >&2 && exit 1
|
|
|
|
OLLIE="${OLLIE:-$HOME/mnt/ollie}"
|
|
plan="$OLLIE/s/$OLLIE_SESSION_ID/plan"
|
|
|
|
current="$(cat "$plan" 2>/dev/null)"
|
|
|
|
added=0
|
|
{
|
|
[ -n "$current" ] && printf '%s\n' "$current"
|
|
for task in "$@"; do
|
|
[ -z "${task// }" ] && continue
|
|
printf -- '- [ ] %s\n' "$task"
|
|
added=$((added + 1))
|
|
done
|
|
} > "$plan"
|
|
|
|
echo "added $added task(s)"
|