|
@@ -6,13 +6,13 @@ GIT=detect
|
|
|
|
|
|
# help-message, /home/swflint/Projects/library/library.org
|
|
# help-message, /home/swflint/Projects/library/library.org
|
|
if [[ $# -eq 0 ]] ; then
|
|
if [[ $# -eq 0 ]] ; then
|
|
- echo "library [ help | query | add | git | bulk-add | report | edit | loan | return-book | init ]"
|
|
|
|
|
|
+ echo "library [ help | query | add | git | bulk-add | report | edit | edit-matching | loan | return-book | init ]"
|
|
exit
|
|
exit
|
|
fi
|
|
fi
|
|
|
|
|
|
function display_help {
|
|
function display_help {
|
|
cat <<EOF
|
|
cat <<EOF
|
|
-library [ help | query | add | git | bulk-add | report | edit | loan | return-book | init ]
|
|
|
|
|
|
+library [ help | query | add | git | bulk-add | report | edit | edit-matching | loan | return-book | init ]
|
|
|
|
|
|
help: Display this help message.
|
|
help: Display this help message.
|
|
query: Query Library Database.
|
|
query: Query Library Database.
|
|
@@ -21,6 +21,7 @@ git: Run a git command.
|
|
bulk-add: Add a specified number of records.
|
|
bulk-add: Add a specified number of records.
|
|
report: Run a report.
|
|
report: Run a report.
|
|
edit: Edit the value of a specified field in a specified record.
|
|
edit: Edit the value of a specified field in a specified record.
|
|
|
|
+edit-matching: Edit records matching a give expression
|
|
loan: Loan a book out.
|
|
loan: Loan a book out.
|
|
return-book:Process a book return
|
|
return-book:Process a book return
|
|
init: Initialize the database.
|
|
init: Initialize the database.
|
|
@@ -180,6 +181,24 @@ function do_edit {
|
|
do_git add `basename ${LIBRARYFILE}`
|
|
do_git add `basename ${LIBRARYFILE}`
|
|
do_git commit -m "Edited record id ${ID}"
|
|
do_git commit -m "Edited record id ${ID}"
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+function do_edit_exp {
|
|
|
|
+ if [[ $# -lt 3 ]] ; then
|
|
|
|
+ echo "ledger edit-matching match-exp field value"
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
+ MATCHEXPRESSION=$1
|
|
|
|
+ shift
|
|
|
|
+ FIELDNAME=$1
|
|
|
|
+ shift
|
|
|
|
+ VALUE=$1
|
|
|
|
+ shift
|
|
|
|
+ recset -e "${MATCHEXPRESSION}" \
|
|
|
|
+ -f "${FIELDNAME}" -S "${VALUE}" \
|
|
|
|
+ ${LIBRARYFILE}
|
|
|
|
+ do_git add $(basename ${LIBRARYFILE})
|
|
|
|
+ do_git commit -m "Edited records"
|
|
|
|
+}
|
|
# edit-field ends here
|
|
# edit-field ends here
|
|
|
|
|
|
# initialize-database, /home/swflint/Projects/library/library.org
|
|
# initialize-database, /home/swflint/Projects/library/library.org
|
|
@@ -292,6 +311,10 @@ case ${COMMAND} in
|
|
do_edit $@
|
|
do_edit $@
|
|
exit
|
|
exit
|
|
;;
|
|
;;
|
|
|
|
+ edit-matching)
|
|
|
|
+ do_edit_exp "$@"
|
|
|
|
+ exit
|
|
|
|
+ ;;
|
|
loan)
|
|
loan)
|
|
do_loan $@
|
|
do_loan $@
|
|
exit
|
|
exit
|