mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-14 02:14:14 +03:00
28 lines
760 B
Haskell
28 lines
760 B
Haskell
{-|
|
|
|
|
A ledger-compatible @print@ command.
|
|
|
|
-}
|
|
|
|
module PrintCommand
|
|
where
|
|
import Prelude hiding (putStr)
|
|
import Ledger
|
|
import Options
|
|
import System.IO.UTF8
|
|
|
|
|
|
-- | Print ledger transactions in standard format.
|
|
print' :: [Opt] -> [String] -> Ledger -> IO ()
|
|
print' opts args l = putStr $ showLedgerTransactions opts args l
|
|
|
|
showLedgerTransactions :: [Opt] -> [String] -> Ledger -> String
|
|
showLedgerTransactions opts args l = concatMap showLedgerTransaction $ filteredtxns
|
|
where
|
|
filteredtxns = ledger_txns $
|
|
filterRawLedgerPostingsByDepth depth $
|
|
filterRawLedgerTransactionsByAccount apats $
|
|
rawledger l
|
|
depth = depthFromOpts opts
|
|
(apats,_) = parsePatternArgs args
|