|
@@ -59,8 +59,7 @@ As a person who has a lot of books, I like to be able to keep track of them. I'
|
|
|
#+TOC: headlines 3
|
|
|
#+TOC: listings
|
|
|
|
|
|
-* DONE File Format
|
|
|
-CLOSED: [2016-10-06 Thu 17:29]
|
|
|
+* WORKING File Format
|
|
|
:PROPERTIES:
|
|
|
:CREATED: <2016-04-13 Wed 20:17>
|
|
|
:ID: 1745de61-6511-4257-bed8-112df2362fe7
|
|
@@ -98,8 +97,10 @@ The following defines the format of book records, which are used to describe eac
|
|
|
%type: Location line
|
|
|
%type: Withdrawn date
|
|
|
%type: Inserted date
|
|
|
+ %type: LoanTo line
|
|
|
+ %type: LoanOn date
|
|
|
%mandatory: Title Author LCCN Inserted
|
|
|
- %allowed: ISBN Publisher Copyright Location Withdrawn
|
|
|
+ %allowed: ISBN Publisher Copyright Location Withdrawn LoanTo LoanOn
|
|
|
%auto: ID Inserted
|
|
|
#+END_SRC
|
|
|
|
|
@@ -139,6 +140,10 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
#+Name: handle-git
|
|
|
#+BEGIN_SRC sh
|
|
|
function do-git {
|
|
|
+ if [[ $# -lt 1 ]] ; then
|
|
|
+ echo "library git args*"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
FIRST=$1
|
|
|
if [[ $FIRST == "init" ]] ; then
|
|
|
OLD=`pwd`
|
|
@@ -218,6 +223,10 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
#+Name: add-in-bulk
|
|
|
#+BEGIN_SRC sh
|
|
|
function bulk-add {
|
|
|
+ if [[ $@ -lt 1 ]] ; then
|
|
|
+ echo "library bulk-add number"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
GITOLD=${GIT}
|
|
|
GIT=FALSE
|
|
|
for i in {1..$1} ; do
|
|
@@ -254,6 +263,10 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
#+Name: handle-reports
|
|
|
#+BEGIN_SRC sh
|
|
|
function do-report {
|
|
|
+ if [[ $# -lt 1 ]] ; then
|
|
|
+ echo "library report name args*"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
NAME=$1
|
|
|
shift
|
|
|
case ${NAME} in
|
|
@@ -264,9 +277,13 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
done
|
|
|
;;
|
|
|
new)
|
|
|
+ if [[ $# -lt 1 ]] ; then
|
|
|
+ echo "library report new name"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
REPORT=$1
|
|
|
shift
|
|
|
- echo "# -*- mode: sh-script -*-" > ${LIBRARYDIRECTORY}/${REPORT}.report
|
|
|
+ echo "# -*- mode: shell-script -*-" > ${LIBRARYDIRECTORY}/${REPORT}.report
|
|
|
emacsclient --alternate-editor="" -n ${LIBRARYDIRECTORY}/${REPORT}.report
|
|
|
;;
|
|
|
,*)
|
|
@@ -287,6 +304,10 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
#+Name: edit-field
|
|
|
#+BEGIN_SRC sh
|
|
|
function do-edit {
|
|
|
+ if [[ $# -lt 2 ]] ; then
|
|
|
+ echo "ledger edit id field [ value ]"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
ID=$1
|
|
|
shift
|
|
|
FIELD=$1
|
|
@@ -294,7 +315,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
|
|
|
if [[ $FIELD = "Withdrawn" ]] ; then
|
|
|
recset -e "ID = ${ID}" \
|
|
|
- -f "Withdrawn" -S `date "%a, %d %b %Y %H:%M:%S %z"` \
|
|
|
+ -f "Withdrawn" -S "`date +"%a, %d %b %Y %H:%M:%S %z"`" \
|
|
|
${LIBRARYFILE}
|
|
|
else
|
|
|
VALUE=$1
|
|
@@ -308,6 +329,57 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
}
|
|
|
#+END_SRC
|
|
|
|
|
|
+* WORKING Loan
|
|
|
+:PROPERTIES:
|
|
|
+:CREATED: <2016-10-24 Mon 19:39>
|
|
|
+:ID: 42dddddc-ab8b-435c-920a-df4463b3c246
|
|
|
+:END:
|
|
|
+
|
|
|
+#+Caption: Handle Loaning
|
|
|
+#+Name: loan
|
|
|
+#+BEGIN_SRC sh
|
|
|
+ function do-loan {
|
|
|
+ if [[ $# -lt 2 ]] ; then
|
|
|
+ echo "library loan id name"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+
|
|
|
+ ID=$1
|
|
|
+ shift
|
|
|
+ NAME=$1
|
|
|
+ shift
|
|
|
+
|
|
|
+ recset -e "ID = ${ID}" \
|
|
|
+ -f "LoanTo" -S "${NAME}" \
|
|
|
+ ${LIBRARYFILE}
|
|
|
+ recset -e "ID = ${ID}" \
|
|
|
+ -f "LoanOn" -S "`date +"%a, %d %b %Y %H:%M:%S %z"`" \
|
|
|
+ ${LIBRARYFILE}
|
|
|
+ do-git add `basename ${LIBRARYFILE}`
|
|
|
+ do-git commit -m "Loaned Book ${ID} to ${NAME}"
|
|
|
+ }
|
|
|
+
|
|
|
+ function do-return {
|
|
|
+ if [[ $# -lt 1 ]] ; then
|
|
|
+ echo "library return-book id"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+
|
|
|
+ ID=$1
|
|
|
+ shift
|
|
|
+
|
|
|
+ recset -e "ID = ${ID}" \
|
|
|
+ -f "LoanTo" -d \
|
|
|
+ ${LIBRARYFILE}
|
|
|
+ recset -e "ID = ${ID}" \
|
|
|
+ -f "LoanOn" -d \
|
|
|
+ ${LIBRARYFILE}
|
|
|
+
|
|
|
+ do-git add `basename ${LIBRARYFILE}`
|
|
|
+ do-git commit -m "Returned Book ${ID}"
|
|
|
+ }
|
|
|
+#+END_SRC
|
|
|
+
|
|
|
* WORKING Help Message
|
|
|
:PROPERTIES:
|
|
|
:CREATED: <2016-04-13 Wed 22:04>
|
|
@@ -318,23 +390,25 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
#+Name: help-message
|
|
|
#+BEGIN_SRC sh
|
|
|
if [[ $# -eq 0 ]] ; then
|
|
|
- echo "library [ help | query query-expressions | add | emacs | git [ other-args ] | bulk-add number | report [ name | list | new name ] | edit id field [ value ] | init ]"
|
|
|
+ echo "library [ help | query | add | emacs | git | bulk-add | report | edit | loan | do-return | init ]"
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
function display-help {
|
|
|
cat <<EOF
|
|
|
- library [ help | query query-expressions | add | emacs | git [ other-args ] | bulk-add number | report [ name | list | new name ] | edit id field [ value ] | init ]
|
|
|
-
|
|
|
- help: Display this help message.
|
|
|
- query: Query Library Database.
|
|
|
- add: Add a singular book record.
|
|
|
- emacs: View records in emacs.
|
|
|
- edit: Edit the value of a specified field in a specified record.
|
|
|
- git: Run a git command.
|
|
|
- report: Run a report.
|
|
|
- init: Initialize the database.
|
|
|
- bulk-add: Add a specified number of records.
|
|
|
+ library [ help | query | add | emacs | git | bulk-add | report | edit | loan | do-return | init ]
|
|
|
+
|
|
|
+ help: Display this help message.
|
|
|
+ query: Query Library Database.
|
|
|
+ add: Add a singular book record.
|
|
|
+ emacs: View records in emacs.
|
|
|
+ git: Run a git command.
|
|
|
+ bulk-add: Add a specified number of records.
|
|
|
+ report: Run a report.
|
|
|
+ edit: Edit the value of a specified field in a specified record.
|
|
|
+ loan: Loan a book out.
|
|
|
+ do-return: Process a book return
|
|
|
+ init: Initialize the database.
|
|
|
EOF
|
|
|
}
|
|
|
#+END_SRC
|
|
@@ -384,6 +458,14 @@ This handles git as needed, by first checking to see if the first argument is ~i
|
|
|
do-edit $@
|
|
|
exit
|
|
|
;;
|
|
|
+ loan)
|
|
|
+ do-loan $@
|
|
|
+ exit
|
|
|
+ ;;
|
|
|
+ return-book)
|
|
|
+ do-return $@
|
|
|
+ exit
|
|
|
+ ;;
|
|
|
init)
|
|
|
initialize
|
|
|
exit
|
|
@@ -428,5 +510,7 @@ Finally, this is what puts the application together. Placing each function in i
|
|
|
|
|
|
<<view-in-emacs>>
|
|
|
|
|
|
+ <<loan>>
|
|
|
+
|
|
|
<<process-commands>>
|
|
|
#+END_SRC
|