bkeep

book management software
git clone git://git.benoneill.xyz/bkeep
Log | Files | Refs | README | LICENSE

commit e69cab8ab5b38f45129cf14cb41bcd39e78d2995
parent 3a301446b524ca0b56191697fd360e7b9b1576ec
Author: Ben O'Neill <ben@benoneill.xyz>
Date:   Mon, 30 Dec 2019 11:52:00 -0500

Begin improving editing system

Diffstat:
Mbkeep | 13+++++++++++--
Mbkeep_curses | 56+++++++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 58 insertions(+), 11 deletions(-)

diff --git a/bkeep b/bkeep @@ -54,6 +54,16 @@ edit_book() { \ ID="$input" else ID="$1" + if [ ! -z "$2" ] && [ ! -z "$3" ]; then + echo "boom" + FIELD="$2" + VALUE="$3" + case "$FIELD" in + "Title") sed -i "$ID s/.*\t/$VALUE\t/" "$outfile" ;; + "Author") sed -i "$ID s/\t.*\t/\t$VALUE\t/" "$outfile" ;; + esac + return + fi fi TITLE="$(sed -n "$ID"p "$outfile" | awk -F '\t' '{print $1}')" @@ -86,7 +96,6 @@ grep_book() { \ else grepstr="$1" fi - bookline="$(awk -F "\t" '{OFS="\n"; print $5}' "$outfile" | grep -inw "$grepstr" | cut -d ':' -f 1)" [ ! -z "$bookline" ] && print_book "$(sed -n "$bookline"p "$outfile")" "$bookline" @@ -137,7 +146,7 @@ else case $1 in 'a') add_book "$2" "$3" "$4" "$5" "$6" ;; 'c') cite_book "$2" "$3" ;; - 'e') edit_book "$2" ;; + 'e') edit_book "$2" "$3" "$4" ;; 'g') grep_book "$2" ;; 'l') list_books ;; 'r') rm_book $2 ;; diff --git a/bkeep_curses b/bkeep_curses @@ -1,17 +1,55 @@ #!/bin/sh -add() { \ - TITLE="$(dialog --title "bkeep" --inputbox "Please enter the title of the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit - AUTHOR="$(dialog --title "bkeep" --inputbox "Please enter the author of the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit - DESCRIPTION="$(dialog --title "bkeep" --inputbox "Please enter a short description of the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit - ISBN="$(dialog --title "bkeep" --inputbox "Please enter the ISBN of the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit - TAGS="$(dialog --title "bkeep" --inputbox "Please enter some comma-separated tags for the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit - bkeep a "$TITLE" "$AUTHOR" "$DESCRIPTION" "$ISBN" "$TAGS" +add_entry() { \ + TITLE="$(dialog --title "bkeep" --inputbox "Please enter the title of the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit + AUTHOR="$(dialog --title "bkeep" --inputbox "Please enter the author of the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit + DESCRIPTION="$(dialog --title "bkeep" --inputbox "Please enter a short description of the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit + ISBN="$(dialog --title "bkeep" --inputbox "Please enter the ISBN of the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit + TAGS="$(dialog --title "bkeep" --inputbox "Please enter some comma-separated tags for the book." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit + bkeep a "$TITLE" "$AUTHOR" "$DESCRIPTION" "$ISBN" "$TAGS" +} + +cite_entry() { \ + clear + echo "Unimplemented" +} + +edit_entry() { \ + ID="$(dialog --title "bkeep" --inputbox "Please enter the ID of the book to edit." 10 60 3>&1 1>&2 2>&3 3>&1)" || exit + editing="yes" + while [ $editing = "yes" ]; do + FIELD="$(dialog --title "bkeep" --menu "What do you want to edit?" 10 70 2 Title "" Author "" Description "" ISBN "" Tags "" 3>&1 1>&2 2>&3 3>&1)" || exit + case "$FIELD" in + "Title") VALUE="$(dialog --title "bkeep" --inputbox "Enter the new title for the book" 10 60 3>&1 1>&2 2>&3 3>&1)" || exit ;; + "Author") VALUE="$(dialog --title "bkeep" --inputbox "Enter the new author for the book" 10 60 3>&1 1>&2 2>&3 3>&1)" || exit ;; + esac + bkeep e "$ID" "$FIELD" "$VALUE" + done +} + +grep_entry() { \ + clear + echo "Unimplemented" +} + +list_entries() { \ + clear + echo "Unimplemented" +} + +rm_entry() { \ + clear + echo "Unimplemented" } res="$(dialog --title "bkeep" --menu "What would you like to do" 10 70 2 Add "Add a new book" Cite "Generate a citation for a book" Edit "Modify an entry" Grep "Find an entry through a regex query" List "List all books" Remove "Remove a book by ID" 3>&1 1>&2 2>&3 3>&1)" case "$res" in - "Add") add ;; - *) echo "Invalid response" ;; + "Add") add_entry ;; + "Cite") cite_entry ;; + "Edit") edit_entry ;; + "Grep") grep_entry ;; + "List") list_entries ;; + "Remove") rm_entry ;; + *) clear; echo "Invalid response" ;; esac