hledger/bin
2021-07-11 14:24:54 -10:00
..
_hledger-chart.hs lib,cli,ui,bin: Eliminate all uses of Mixed outside of Hledger.Data.Amount. 2021-03-18 09:47:59 +11:00
_scripts8.2.test ;ci: give up on bin/ compilation tests for now (#1453) 2021-01-12 15:00:13 -08:00
.gitignore prices: new addon (#486) 2017-01-25 11:50:54 -08:00
aliases.sh move add-ons and scripts to bin/ 2017-01-08 07:28:23 -08:00
commitlint bin:commitlint:doc, policy: allow more spaces, slash/comma in topics 2021-07-11 14:24:54 -10:00
compile.sh ;bin: linux/pr CI uses ghc 8.2, make functest uses default ghc (#1453) 2021-01-12 12:11:56 -08:00
csv.mk doc: move last addon docs out of hledger manual; add hledger-iadd 2017-01-24 15:39:38 -08:00
hledger-balance-as-budget.hs ;bin: doc 2021-01-12 11:07:29 -08:00
hledger-check-fancyassertions.hs lib,cli,ui,bin: Remove unnecessary normalisedMixedAmount, replace 2021-05-01 09:45:29 -10:00
hledger-check-tagfiles.cabal.hs bin: rename hledger-check* per "How to check for errors" 2020-11-27 12:29:54 -08:00
hledger-check-tagfiles.hs ;bin: doc 2021-01-12 11:07:29 -08:00
hledger-combine-balances.hs lib,cli,ui,bin: Create a new API for MixedAmount arithmetic. This should 2021-03-18 09:47:21 +11:00
hledger-print-location.hs bin: more robust --package syntax, comma form sometimes fails 2021-02-12 13:55:31 -08:00
hledger-smooth.hs lib: Change internal representation of MixedAmount to use a strict Map 2021-05-01 09:45:29 -10:00
hledger-swap-dates.hs lib,cli,web,bin: Replace journalSelectingAmountFromOpts with journalApplyValuationFromOpts. 2021-06-08 14:55:05 +10:00
README.md ;bin: readme updates 2021-01-12 15:11:20 -08:00
scripts.test ;bin: ignore stderr in func tests, check only exit code 2021-01-29 12:09:58 -08:00

Miscellaneous hledger add-ons, bash scripts, example make rules, etc. Things in this directory can be unfinished or out of date.

hledger scripts

The hledger-*.hs scripts here are example/experimental hledger add-on commands. See https://hledger.org/scripting.html for more about this.

They are mostly implemented as stack runghc scripts. See the comments in hledger-check-fancyassertions.hs for more about how to run or compile them. Short version: run bin/compile.sh to compile all scripts, and add this directory to your $PATH so they show up in hledger's command list.

Scripts overview, simplest first:

  • hledger-check-tagfiles.hs - check that all tag values containing / exist as file paths
  • hledger-check-tagfiles.cabal.hs - the above as a cabal script
  • hledger-swap-dates.hs - print transactions with their date and date2 fields swapped
  • hledger-print-location.hs - add file path/line number tags to the print command
  • hledger-balance-as-budget.hs - use one balance report as budget goals for another one
  • hledger-combine-balances.hs - show balance reports for two different periods side by side
  • hledger-smooth.hs - incomplete attempt at automatically splitting infrequent/irregular transactions
  • hledger-check-fancyassertions.hs - check more complex account balance assertions

How to:

Install all scripts as add-on commands

$ git clone https://github.com/simonmichael/hledger
$ hledger/bin/compile.sh
$ export PATH=$PATH:$PWD/hledger/bin

$ hledger                           # scripts now appear in commands list
$ hledger-print-location --help     # run a script directly
$ hledger print-location -- --help  # or run it via hledger. -- is needed before script options

Create a new script

The example scripts follow a template that implements hledger's standard command line options and help, so it's a good idea to use one as your starting point. The hledger- naming is not required, but it causes scripts to show up in the hledger commands list. On unix, your new script should be marked executable. This should do it:

$ cd hledger
$ cp bin/hledger-swap-dates.hs bin/hledger-foo.hs  # and edit, at least the command name and help
$ stack install string-qq     # ensure any extra script deps are installed
$ bin/hledger-cmd.hs --help
foo [OPTIONS]
  My new foo command.
  ...
$ stack ghc bin/hledger-cmd.hs
$ hledger foo -- --help
foo [OPTIONS]
  My new foo command.
  ...

Run ghcid on a script

$ stack install string-qq     # ensure any extra script deps are installed
$ stack exec -- ghcid bin/hledger-foo.hs 
...
Ok, one module loaded.
All good (1 module, at 10:50:48)

Run ghci on a script

$ stack install string-qq     # ensure any extra script deps are installed
$ stack ghci bin/hledger-foo.hs 
...
Ok, one module loaded.
...
ghci>