#!/usr/bin/env zsh
use office/memo
#####################################################################

MAIN() {
	local MEMO_NAME=$(MEMO__LIST_ALL | utils.fzf 'select a memo to delete')
	local MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
	[ "$MEMO_NAME" ] && [ -f "$MEMO_FILE" ] || user.abort

	echo.status "--- START OF MEMO ---------------------------------------------------"
	cat "$MEMO_FILE"
	echo.status "--- END OF MEMO -----------------------------------------------------"

	echo.warning '
		memos are not backed up by default; deletion is permanent!
	'

	yN 'are you sure you want to delete this memo?' || user.abort

	echo.status "deleting memo '$MEMO_FILE'"
	rm "$MEMO_FILE" \
		&& echo.success "removed memo '$MEMO_NAME'" \
		|| utils.fail 1 "failed to remove memo '$MEMO_NAME'" \
		;
}
