hledger/PrintCommand.hs

26 lines
723 B
Haskell
Raw Normal View History

{-|
A ledger-compatible @print@ command.
-}
module PrintCommand
where
import Ledger
import Options
-- | Print ledger transactions in standard format.
2008-10-12 13:17:21 +04:00
print' :: [Opt] -> [String] -> Ledger -> IO ()
print' opts args l = putStr $ showLedgerTransactions opts args l
2008-10-12 13:17:21 +04:00
showLedgerTransactions :: [Opt] -> [String] -> Ledger -> String
showLedgerTransactions opts args l = concatMap showLedgerTransaction $ filteredtxns
2008-11-22 09:35:10 +03:00
where
filteredtxns = ledger_txns $
filterRawLedgerPostingsByDepth depth $
filterRawLedgerTransactionsByAccount apats $
2009-04-02 10:02:00 +04:00
rawledger l
depth = depthFromOpts opts
(apats,_) = parseAccountDescriptionArgs opts args