|
@@ -109,6 +109,14 @@ As a person who has a lot of books, I like to be able to keep track of them. I'
|
|
|
do_return "$@"
|
|
|
exit
|
|
|
;;
|
|
|
+ withdraw)
|
|
|
+ do_withdraw "$@"
|
|
|
+ exit
|
|
|
+ ;;
|
|
|
+ drop-withdrawn)
|
|
|
+ remove_withdrawn "$@"
|
|
|
+ exit
|
|
|
+ ;;
|
|
|
init)
|
|
|
initialize
|
|
|
exit
|
|
@@ -382,21 +390,13 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
shift
|
|
|
FIELD=$1
|
|
|
shift
|
|
|
+ VALUE=$1
|
|
|
+ shift
|
|
|
+
|
|
|
+ TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
+ -f "${FIELD}" -S "${VALUE}" \
|
|
|
+ "${LIBRARY_FILE}"
|
|
|
|
|
|
- if [[ $FIELD = "Withdrawn" ]] ; then
|
|
|
- TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
- -f "Withdrawn" -S "`date +"%a, %d %b %Y %H:%M:%S %z"`" \
|
|
|
- "${LIBRARY_FILE}"
|
|
|
- TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
- -f "Location" -S "WITHDRAWN" \
|
|
|
- "${LIBRARY_FILE}"
|
|
|
- else
|
|
|
- VALUE=$1
|
|
|
- shift
|
|
|
- TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
- -f "${FIELD}" -S "${VALUE}" \
|
|
|
- "${LIBRARY_FILE}"
|
|
|
- fi
|
|
|
do_git add `basename "${LIBRARY_FILE}"`
|
|
|
do_git commit -m "Edited record id ${ID}"
|
|
|
}
|
|
@@ -413,8 +413,8 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
VALUE=$1
|
|
|
shift
|
|
|
TMPDIR=. recset -e "${MATCHEXPRESSION}" \
|
|
|
- -f "${FIELDNAME}" -S "${VALUE}" \
|
|
|
- "${LIBRARY_FILE}"
|
|
|
+ -f "${FIELDNAME}" -S "${VALUE}" \
|
|
|
+ "${LIBRARY_FILE}"
|
|
|
do_git add $(basename "${LIBRARY_FILE}")
|
|
|
if [[ $1 != "" ]] ; then
|
|
|
do_git commit -m "${1}"
|
|
@@ -424,6 +424,35 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
}
|
|
|
#+END_SRC
|
|
|
|
|
|
+* WORKING Withdrawing Books
|
|
|
+:PROPERTIES:
|
|
|
+:ID: 190e248e-4102-431e-ba8b-288e71c10660
|
|
|
+:END:
|
|
|
+
|
|
|
+#+Caption: Withdrawing Books
|
|
|
+#+Name: withdraw-books
|
|
|
+#+BEGIN_SRC sh
|
|
|
+ function do_withdraw {
|
|
|
+ if [ $# -lt 1 ] ; then
|
|
|
+ echo "library withdraw id"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+ ID=$1
|
|
|
+ TMPDIR=. recset -e "ID = ${ID}" \
|
|
|
+ -f "Withdrawn" -S "`date +"%a, %d %b %Y %H:%M:%S %z"`" \
|
|
|
+ -f "Location" -S "WITHDRAWN" \
|
|
|
+ "${LIBRARY_FILE}"
|
|
|
+ do_git add $(basename ${LIBRARY_FILE})
|
|
|
+ do_git commit -m "Withdrew book ${ID}"
|
|
|
+ }
|
|
|
+
|
|
|
+ function remove_withdrawn {
|
|
|
+ TMPDIR=. recdel -t Book \
|
|
|
+ -e "Location ~ \"WITHDRAWN\"" \
|
|
|
+ "${LIBRARY_FILE}"
|
|
|
+ }
|
|
|
+#+END_SRC
|
|
|
+
|
|
|
* WORKING Loan
|
|
|
:PROPERTIES:
|
|
|
:CREATED: <2016-10-24 Mon 19:39>
|
|
@@ -502,7 +531,7 @@ To complete this program, I include a help message, a small part of which is dis
|
|
|
#+Name: help-message
|
|
|
#+BEGIN_SRC sh
|
|
|
if [[ $# -eq 0 ]] ; then
|
|
|
- echo "library [ help | query | add | git | bulk-add | report | edit | edit-matching | loan | return-book | init ]"
|
|
|
+ echo "library [ help | query | add | git | bulk-add | report | edit | edit-matching | loan | return-book | withdraw | drop-withdrawn | init ]"
|
|
|
exit
|
|
|
fi
|
|
|
|
|
@@ -520,6 +549,8 @@ To complete this program, I include a help message, a small part of which is dis
|
|
|
edit-matching: Edit records matching a give expression
|
|
|
loan: Loan a book out.
|
|
|
return-book:Process a book return
|
|
|
+ withdraw: Withdraw a specified book
|
|
|
+ drop-withdrawn: Drop withdrawn books
|
|
|
init: Initialize the database.
|
|
|
EOF
|
|
|
}
|
|
@@ -553,6 +584,8 @@ Finally, this is what puts the application together. Placing each function in i
|
|
|
|
|
|
<<edit-field>>
|
|
|
|
|
|
+ <<withdraw-books>>
|
|
|
+
|
|
|
<<initialize-database>>
|
|
|
|
|
|
<<loan>>
|