;bin: register-max: don't add -H by default
This commit is contained in:
parent
82abb00754
commit
dc8e0f66de
@ -1,16 +1,16 @@
|
||||
#!/usr/bin/env stack
|
||||
-- stack script --compile --resolver lts-20.8 --verbosity error --package hledger-lib --package hledger --package text
|
||||
|
||||
-- hledger-register-max - runs "register -H" and prints the posting with largest historical balance
|
||||
-- hledger-register-max - runs "hledger register" and prints the posting with largest running total/balance.
|
||||
-- Usage:
|
||||
-- hledger-register-max [REGISTERARGS]
|
||||
-- hledger register-max -- [REGISTERARGS]
|
||||
-- For negative balances, use --invert.
|
||||
-- For historical balances, add -H. For negative balances, add --invert.
|
||||
|
||||
-- Examples:
|
||||
-- $ hledger-register-max -f examples/bcexample.hledger checking
|
||||
-- $ hledger-register-max -f examples/bcexample.hledger -H checking
|
||||
-- 2013-01-03 Hoogle | Payroll Assets:US:BofA:Checking 1350.60 USD 8799.22 USD
|
||||
-- $ hledger register-max -- -f examples/bcexample.hledger checking
|
||||
-- $ hledger register-max -- -f examples/bcexample.hledger -H checking
|
||||
-- 2013-01-03 Hoogle | Payroll Assets:US:BofA:Checking 1350.60 USD 8799.22 USD
|
||||
|
||||
|
||||
@ -28,18 +28,19 @@ import Hledger
|
||||
import Hledger.Cli
|
||||
import Hledger.Cli.Main (argsToCliOpts)
|
||||
|
||||
-- needs --help, see hledger-addon-example.hs
|
||||
-- XXX needs --help, see hledger-addon-example.hs
|
||||
-- XXX shows only one posting when multiple have same balance
|
||||
|
||||
main = do
|
||||
args <- getArgs
|
||||
opts <- argsToCliOpts ("register" : "-H" : args) []
|
||||
opts <- argsToCliOpts ("register" : args) []
|
||||
withJournalDo opts $ \j -> do
|
||||
let r = postingsReport (reportspec_ opts) j
|
||||
unless (null r) $ do
|
||||
let
|
||||
i = maximumBy (comparing fifth5) r
|
||||
(_, _, mdesc, p, _) = i
|
||||
d = maybe (error "shouldn't happen") tdate $ ptransaction p
|
||||
d = postingDate p
|
||||
desc = fromMaybe "" mdesc
|
||||
ptxt = T.strip $ T.unlines $ first3 $ postingAsLines False True 20 15 p
|
||||
T.putStrLn $ T.unwords [showDate d, desc, "", ptxt, "", T.pack $ showMixedAmountOneLine $ fifth5 i]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user