feat: add --csv flag to atm-transactions helper
This commit is contained in:
parent
e5d7a86bc2
commit
b147c7e5d7
1 changed files with 8 additions and 1 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
# atm-transactions --since 2026-02-28 # Since a date
|
# atm-transactions --since 2026-02-28 # Since a date
|
||||||
# atm-transactions --summary # Summary totals only
|
# atm-transactions --summary # Summary totals only
|
||||||
# atm-transactions --inventory # Current cassette & cashbox state
|
# atm-transactions --inventory # Current cassette & cashbox state
|
||||||
|
# atm-transactions --csv # Output as CSV (pipe to file)
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
@ -20,8 +21,10 @@ if [ ! -f "$DB" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
FORMAT="-column -header"
|
||||||
|
|
||||||
sql() {
|
sql() {
|
||||||
sqlite3 -column -header "$DB" "$1"
|
sqlite3 $FORMAT "$DB" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
|
|
@ -31,6 +34,7 @@ SINCE=""
|
||||||
SUMMARY=false
|
SUMMARY=false
|
||||||
INVENTORY=false
|
INVENTORY=false
|
||||||
TODAY=false
|
TODAY=false
|
||||||
|
CSV=false
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
@ -46,6 +50,8 @@ while [[ $# -gt 0 ]]; do
|
||||||
SUMMARY=true; shift ;;
|
SUMMARY=true; shift ;;
|
||||||
--inventory)
|
--inventory)
|
||||||
INVENTORY=true; shift ;;
|
INVENTORY=true; shift ;;
|
||||||
|
--csv)
|
||||||
|
CSV=true; FORMAT="-csv -header"; shift ;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
echo "Usage: atm-transactions [OPTIONS]"
|
echo "Usage: atm-transactions [OPTIONS]"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -56,6 +62,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
echo " --today Show today's transactions"
|
echo " --today Show today's transactions"
|
||||||
echo " --summary Show summary totals"
|
echo " --summary Show summary totals"
|
||||||
echo " --inventory Show cassette & cashbox state"
|
echo " --inventory Show cassette & cashbox state"
|
||||||
|
echo " --csv Output as CSV (pipe to file)"
|
||||||
echo " -h, --help Show this help"
|
echo " -h, --help Show this help"
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*)
|
*)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue