feat: add edit command

This commit is contained in:
Viktor Varland 2021-01-26 13:23:54 +01:00
parent d3ff11220b
commit dbfde13372

View file

@ -29,7 +29,6 @@ year="$(date +%Y)"
week="$(date -d "$base_monday" +%V)" week="$(date -d "$base_monday" +%V)"
fname="${time_dir}/${year}-${week}".timedot fname="${time_dir}/${year}-${week}".timedot
current="${time_dir}/current.timedot"
# #
## support functions ## support functions
@ -87,15 +86,21 @@ case "$command" in
echo "File exists: $fname" echo "File exists: $fname"
fi fi
;; ;;
edit)
if [[ -f $fname ]]; then
$EDITOR "$fname"
else
echo "File does not exist: $fname"
fi
;;
*) *)
echo "Usage: generate-week.sh <command> [<args>]" echo "Usage: generate-week.sh <command> [<args>]"
echo "" echo ""
echo "Commands: print, write" echo "Commands: print, write, edit"
echo "Args: datestring in format: YYYY-MM-DD (+%Y-%m-%d)" echo "Args: datestring in format: YYYY-MM-DD (+%Y-%m-%d)"
echo "" echo ""
echo "Generate a weekly timedot file. Week starts on Monday." echo "Generate a weekly timedot file. Week starts on Monday."
echo "Does not print the TEMPLATE string on Sat/Sun." echo "Does not print the TEMPLATE string on Sat/Sun."
echo "Updates symlink to current.timedot in the TIME_DIR."
echo "" echo ""
echo "Environment variables:" echo "Environment variables:"
echo "TIME_DIR Output directory, defaults to current directory." echo "TIME_DIR Output directory, defaults to current directory."