delete functionality
This commit is contained in:
parent
8824959715
commit
5d8b913d78
37
src/main.sh
37
src/main.sh
@ -308,6 +308,15 @@ if [ -z "${WEEKLY_DATA_FILE:-}" ]; then
|
|||||||
export WEEKLY_DATA_FILE
|
export WEEKLY_DATA_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${1:-}" = "--help" ]; then
|
||||||
|
echo "Usage: $0 [OPTION]"
|
||||||
|
echo ""
|
||||||
|
echo "You may specify at most one option."
|
||||||
|
echo " --help Show this help and exit"
|
||||||
|
echo " --new Create new entry"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--new" ]; then
|
if [ "${1:-}" = "--new" ]; then
|
||||||
collection=$(echo "$COLLECTION_LABELS" | tr ';' '\n' | $FZF --delimiter='=' --with-nth=2 --accept-nth=1)
|
collection=$(echo "$COLLECTION_LABELS" | tr ';' '\n' | $FZF --delimiter='=' --with-nth=2 --accept-nth=1)
|
||||||
fpath=""
|
fpath=""
|
||||||
@ -355,6 +364,31 @@ if [ "${1:-}" = "--preview" ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${1:-}" = "--delete" ]; then
|
||||||
|
fpath=$(echo "$2" | cut -d '|' -f 4 | sed "s/ /|/g")
|
||||||
|
if [ -n "$fpath" ]; then
|
||||||
|
fpath="$ROOT/$fpath"
|
||||||
|
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath")
|
||||||
|
while true; do
|
||||||
|
printf "Do you want to delete the entry with the title \"%s\"? (yes/no): " "$summary" >/dev/tty
|
||||||
|
read -r yn
|
||||||
|
case $yn in
|
||||||
|
"yes")
|
||||||
|
rm -v "$fpath"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"no")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Please answer \"yes\" or \"no\"." >/dev/tty
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
exec $0 --day "$DISPLAY_DATE"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--day-reload" ]; then
|
if [ "${1:-}" = "--day-reload" ]; then
|
||||||
__show_day
|
__show_day
|
||||||
exit
|
exit
|
||||||
@ -379,7 +413,8 @@ if [ "${1:-}" = "--day" ]; then
|
|||||||
--accept-nth='1,2,3,4' \
|
--accept-nth='1,2,3,4' \
|
||||||
--preview="$0 --preview {}" \
|
--preview="$0 --preview {}" \
|
||||||
--expect="ctrl-n" \
|
--expect="ctrl-n" \
|
||||||
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)"
|
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \
|
||||||
|
--bind="ctrl-alt-d:become($0 --delete {})"
|
||||||
)
|
)
|
||||||
key=$(echo "$selection" | head -1)
|
key=$(echo "$selection" | head -1)
|
||||||
line=$(echo "$selection" | tail -1)
|
line=$(echo "$selection" | tail -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user