mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
29 lines
619 B
Bash
29 lines
619 B
Bash
|
#!/bin/bash
|
||
|
set -e -o pipefail
|
||
|
|
||
|
function usage() {
|
||
|
echo "USAGE: $0 /path/to/hledger.journal [web|bash|hledger [hledger-args]]"
|
||
|
}
|
||
|
|
||
|
journal=$(readlink -f "$1")
|
||
|
shift
|
||
|
[ -f "$journal" ] || { usage; exit 1; }
|
||
|
dir=$(dirname $journal)
|
||
|
file=$(basename $journal)
|
||
|
|
||
|
cmd="$1"
|
||
|
shift
|
||
|
|
||
|
case "$cmd" in
|
||
|
web) extra_args="" ;;
|
||
|
bash) extra_args="bash" ;;
|
||
|
hledger) extra_args="hledger" ;;
|
||
|
*)usage; exit 1 ;;
|
||
|
esac
|
||
|
|
||
|
docker container run --rm -it --volume "$dir:/data" \
|
||
|
--env HLEDGER_FILE_NAME=/data/$file \
|
||
|
--env LEDGER_FILE=/data/$file \
|
||
|
-p 5000:5000 -p 5001:5001 \
|
||
|
hledger $extra_args "$@"
|