diff --git a/bin/README.md b/bin/README.md index 6fa93d433..c97568e2d 100644 --- a/bin/README.md +++ b/bin/README.md @@ -6,10 +6,10 @@ Things in this directory can be unfinished or out of date. The hledger-*.hs scripts here are example/experimental hledger [add-on commands]. See for more about this. -They are mostly implemented as [stack] scripts; if you have stack in your $PATH, -they should just work, automatically installing their dependencies if needed. -(You can also run them with [cabal], or runghc, or compile them with -ghc, if you take care of the dependencies yourself.) +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: diff --git a/bin/compile.sh b/bin/compile.sh index 1f54298af..a613e3868 100755 --- a/bin/compile.sh +++ b/bin/compile.sh @@ -1,15 +1,13 @@ #!/bin/sh -# Compile all add-on scrips in this directory. +# Compile all add-on scripts in this directory. cd "$(dirname "$0")" || exit -echo "building hledger libraries" +echo "building hledger libraries for scripts" stack build hledger -echo "installing extra libraries needed by scripts" +echo "installing extra libraries for scripts" stack install string-qq -echo "compiling hledger-* scripts" -for f in hledger-*.hs; do stack ghc -- "$f"; done - # stack script --compile would install extra libs more automatically - # but would also run scripts, which we don't want +echo "compiling the hledger-* scripts" +for f in `git ls-files 'hledger-*.hs'`; do stack ghc -- "$f"; done diff --git a/bin/hledger-balance-as-budget.hs b/bin/hledger-balance-as-budget.hs index 77d49a138..53db9c740 100755 --- a/bin/hledger-balance-as-budget.hs +++ b/bin/hledger-balance-as-budget.hs @@ -1,4 +1,5 @@ -#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0 +#!/usr/bin/env stack +-- stack runghc --verbosity info --package hledger -- See hledger-check-fancyassertions.hs -- {-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-} diff --git a/bin/hledger-check-fancyassertions.hs b/bin/hledger-check-fancyassertions.hs index 579e2ba5a..898f36b7e 100755 --- a/bin/hledger-check-fancyassertions.hs +++ b/bin/hledger-check-fancyassertions.hs @@ -1,24 +1,20 @@ -#!/usr/bin/env -S stack ghc --verbosity info --package hledger-lib -- -O0 --- Run this script once from inside the hledger source tree; it will --- compile itself using the corresponding source version of hledger, --- which is the version it is tested with. You can run the compiled --- version from anywhere. It is compiled unoptimised, which takes less --- time and probably won't be noticeable otherwise; if you care, you --- can remove the "-O0" above. +#!/usr/bin/env stack +-- stack runghc --verbosity info --package hledger-lib + +-- Run this script from inside the hledger source tree, so that it +-- will use the corresponding source version of hledger, which is the +-- version it is tested with. -- --- To run it interpreted, eg while tweaking it: replace "ghc" above --- with "runghc", and run from inside the hledger source tree. +-- You can compile these scripts by running compile.sh in this directory. +-- The compiled executables can be run from anywhere, so you could add +-- this directory to your $PATH and see them in hledger's command list. -- --- To make it a standalone script that runs from anywhere and --- recompiles itself when changed: replace "ghc" above with --- "script --compile --resolver lts-16" (eg). --- However this uses the hledger version from that stackage resolver, --- so in this case you should check out the corresponding release-tagged --- version of this script for compatibility (eg: git checkout 1.18.1). --- --- env -S and a multi-argument shebang line is used, rather than a stack --- options line, because current stack won't run the ghc command that way. --- Hopefully your env supports -S. +-- You could make this a standalone script that runs from anywhere and +-- recompiles itself when changed, by replacing "runghc" above with +-- "script --compile --resolver lts-16" (eg). However this uses the +-- hledger version from that stackage resolver, so in this case you +-- should check out the corresponding release-tagged version of this +-- script for compatibility (eg: git checkout 1.18.1). {- ``` diff --git a/bin/hledger-check-tagfiles.hs b/bin/hledger-check-tagfiles.hs index d9051e00d..4c881aae1 100755 --- a/bin/hledger-check-tagfiles.hs +++ b/bin/hledger-check-tagfiles.hs @@ -1,4 +1,5 @@ -#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0 +#!/usr/bin/env stack +-- stack runghc --verbosity info --package hledger -- See hledger-check-fancyassertions.hs {- diff --git a/bin/hledger-combine-balances.hs b/bin/hledger-combine-balances.hs index 9255f2d67..ceaced4d3 100755 --- a/bin/hledger-combine-balances.hs +++ b/bin/hledger-combine-balances.hs @@ -1,4 +1,5 @@ -#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0 +#!/usr/bin/env stack +-- stack runghc --verbosity info --package hledger -- See hledger-check-fancyassertions.hs {-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-} diff --git a/bin/hledger-print-location.hs b/bin/hledger-print-location.hs index 44d8e5de3..b429c5cb9 100755 --- a/bin/hledger-print-location.hs +++ b/bin/hledger-print-location.hs @@ -1,6 +1,6 @@ -#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0 +#!/usr/bin/env stack +-- stack runghc --verbosity info --package hledger -- See hledger-check-fancyassertions.hs - --package string-qq {- diff --git a/bin/hledger-smooth.hs b/bin/hledger-smooth.hs index 10449a5d3..12061a0c5 100755 --- a/bin/hledger-smooth.hs +++ b/bin/hledger-smooth.hs @@ -1,8 +1,9 @@ -#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0 +#!/usr/bin/env stack +-- stack runghc --verbosity info --package hledger -- See hledger-check-fancyassertions.hs - --package string-qq + -- This is an unfinished prototype, see https://github.com/simonmichael/hledger/issues/1171 -- Requires a contemporaneous version of the hledger package. -- Requires journal entries to be sorted by date. diff --git a/bin/hledger-swap-dates.hs b/bin/hledger-swap-dates.hs index cb81735cd..b644875a3 100755 --- a/bin/hledger-swap-dates.hs +++ b/bin/hledger-swap-dates.hs @@ -1,4 +1,5 @@ -#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0 +#!/usr/bin/env stack +-- stack runghc --verbosity info --package hledger -- See hledger-check-fancyassertions.hs {-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-}