feat: add --csv flag to atm-transactions helper

This commit is contained in:
Patrick Mulligan 2026-05-10 07:05:14 -04:00
commit b147c7e5d7

View file

@ -10,6 +10,7 @@
# atm-transactions --since 2026-02-28 # Since a date
# atm-transactions --summary # Summary totals only
# atm-transactions --inventory # Current cassette & cashbox state
# atm-transactions --csv # Output as CSV (pipe to file)
set -euo pipefail
@ -20,8 +21,10 @@ if [ ! -f "$DB" ]; then
exit 1
fi
FORMAT="-column -header"
sql() {
sqlite3 -column -header "$DB" "$1"
sqlite3 $FORMAT "$DB" "$1"
}
# Parse arguments
@ -31,6 +34,7 @@ SINCE=""
SUMMARY=false
INVENTORY=false
TODAY=false
CSV=false
while [[ $# -gt 0 ]]; do
case "$1" in
@ -46,6 +50,8 @@ while [[ $# -gt 0 ]]; do
SUMMARY=true; shift ;;
--inventory)
INVENTORY=true; shift ;;
--csv)
CSV=true; FORMAT="-csv -header"; shift ;;
-h|--help)
echo "Usage: atm-transactions [OPTIONS]"
echo ""
@ -56,6 +62,7 @@ while [[ $# -gt 0 ]]; do
echo " --today Show today's transactions"
echo " --summary Show summary totals"
echo " --inventory Show cassette & cashbox state"
echo " --csv Output as CSV (pipe to file)"
echo " -h, --help Show this help"
exit 0 ;;
*)