1 {-| 2 3 A ledger-compatible @print@ command. 4 5 -} 6 7 module Commands.Print 8 where 9 import Prelude hiding (putStr) 10 import Ledger 11 import Options 12 import System.IO.UTF8 13 14 15 -- | Print ledger transactions in standard format. 16 print' :: [Opt] -> [String] -> Ledger -> IO () 17 print' opts args l = putStr $ showLedgerTransactions opts args l 18 19 showLedgerTransactions :: [Opt] -> [String] -> Ledger -> String 20 showLedgerTransactions opts args l = concatMap showLedgerTransaction $ filteredtxns 21 where 22 filteredtxns = ledger_txns $ 23 filterRawLedgerPostingsByDepth depth $ 24 filterRawLedgerTransactionsByAccount apats $ 25 rawledger l 26 depth = depthFromOpts opts 27 (apats,_) = parsePatternArgs args