dotfiles/overlays/ledger-compat/ledger.sh
magic_rb 60622f12cc
Add hledger to omen
Signed-off-by: magic_rb <richard@brezak.sk>
2023-10-16 14:57:43 +02:00

50 lines
1.1 KiB
Bash

# -*- mode: shell-script -*-
iargs=("$@")
oargs=()
j=0;
date=;
for((i=0; i<${#iargs[@]}; ++i)); do
case ${iargs[i]} in
--date-format)
# drop --date-format and the next arg
i=$((i+1));
;;
--sort)
# drop --sort and the next arg
i=$((i+1));
;;
--limit)
# drop --limit and the next arg
i=$((i+1));
;;
--collapse)
# drop --collapse and the next arg
i=$((i+1));
;;
--uncleared)
oargs[j]="-UP";
j=$((j+1))
;;
xact)
# convert "xact" to "print --match"
oargs[j]=print; oargs[j+1]=--match; j=$((j+2));
# drop xact argument and stash the date argument
i=$((i+1));
date=${iargs[i]};
;;
*)
# keep any other args:
oargs[j]=${iargs[i]};
j=$((j+1));
;;
esac
done
if test "$date"
then
# substitute the given date for the old date:
hledger "${oargs[@]}" | sed "1s/....-..-../$date/"
else
hledger "${oargs[@]}"
fi