diff --git a/extra/hledger-accountnames.hs b/extra/hledger-accountnames.hs index 5349075b3..4948d8244 100755 --- a/extra/hledger-accountnames.hs +++ b/extra/hledger-accountnames.hs @@ -2,8 +2,15 @@ -- Show all account names used in the default journal. import Hledger +import Hledger.Cli (getCliOpts, mainmode, withJournalDo) main = do - j <- defaultJournal - let l = ledgerFromJournal Any j - mapM_ putStrLn $ ledgerAccountNames l + -- simple way to read ~/.hledger.journal or $LEDGER_FILE + -- j <- defaultJournal + + -- but we'd better handle -f as well: + opts <- getCliOpts $ mainmode [] + withJournalDo opts $ \_opts j -> do + + -- query the journal for all account names and print each one + mapM_ putStrLn $ journalAccountNames j diff --git a/extra/hledger-balance-csv.hs b/extra/hledger-balance-csv.hs index 116eb9fe3..3eff16626 100755 --- a/extra/hledger-balance-csv.hs +++ b/extra/hledger-balance-csv.hs @@ -26,7 +26,7 @@ main = getCliOpts argsmode >>= printBalanceCsv printBalanceCsv opts = withJournalDo opts $ \CliOpts{reportopts_=ropts} j -> do d <- getCurrentDay - let (items,_) = accountsReport ropts (queryFromOpts d ropts) j + let (items,_) = balanceReport ropts (queryFromOpts d ropts) j putStrLn $ printCSV $ ["account","balance"] : [[a, showMixedAmountWithoutPrice b] | (a, _, _, b) <- items] diff --git a/extra/hledger-equity.hs b/extra/hledger-equity.hs index afa61370b..e3c2efd71 100755 --- a/extra/hledger-equity.hs +++ b/extra/hledger-equity.hs @@ -17,12 +17,13 @@ import Hledger.Cli import System.Environment main = do + putStrLn "(-f option not supported, see hledger-accountnames.hs for how to add it)" j <- defaultJournal d <- getCurrentDay args <- getArgs let query = Or $ map Acct args ropts = defreportopts{flat_=True} - (acctbals,_) = accountsReport ropts query j + (acctbals,_) = balanceReport ropts query j balancingamt = negate $ sum $ map (\(_,_,_,b) -> b) acctbals ps = [posting{paccount=a, pamount=b} | (a,_,_,b) <- acctbals] ++ [posting{paccount="equity:opening balances", pamount=balancingamt}] diff --git a/extra/hledger-print-unique.hs b/extra/hledger-print-unique.hs index 3417d9b4e..80b004eb9 100755 --- a/extra/hledger-print-unique.hs +++ b/extra/hledger-print-unique.hs @@ -13,6 +13,7 @@ import Hledger import Hledger.Cli main = do + putStrLn "(-f option not supported)" opts <- getCliOpts (defCommandMode ["hledger-print-unique"]) withJournalDo opts $ \opts j@Journal{jtxns=ts} -> print' opts j{jtxns=uniquify ts}