hledger/Commands/Print.hs

28 lines
762 B
Haskell
Raw Normal View History

{-|
A ledger-compatible @print@ command.
-}
2009-06-02 22:29:01 +04:00
module Commands.Print
where
import Prelude hiding (putStr)
import Ledger
import Options
import System.IO.UTF8
-- | 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
2009-04-04 13:14:04 +04:00
(apats,_) = parsePatternArgs args