From 07041e1b651ce751c531ef9fc3df0a5b9588dcf7 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 3 Sep 2015 16:02:44 -0700 Subject: [PATCH] ui: fix --ignore-assertions, perhaps more --- hledger-ui/Hledger/UI/Main.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index 6af2bad34..1b3866984 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -45,15 +45,15 @@ main = do | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeHelp uimode) >> exitSuccess | "version" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess | "binary-filename" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname) - | otherwise = withJournalDo' opts runBrickUi + | otherwise = withJournalDoUICommand opts runBrickUi -withJournalDo' :: UIOpts -> (UIOpts -> Journal -> IO ()) -> IO () -withJournalDo' opts cmd = do - -- journalFilePathFromOpts (cliopts_ opts) >>= readJournalFile Nothing >>= - -- either error' (cmd opts . journalApplyAliases (aliasesFromOpts $ cliopts_ opts)) - -- XXX head should be safe for now - (head `fmap` journalFilePathFromOpts (cliopts_ opts)) >>= readJournalFile Nothing Nothing True >>= - either error' (cmd opts . journalApplyAliases (aliasesFromOpts $ cliopts_ opts)) +-- XXX withJournalDo specialised for UIOpts +withJournalDoUICommand :: UIOpts -> (UIOpts -> Journal -> IO ()) -> IO () +withJournalDoUICommand uopts@UIOpts{cliopts_=copts} cmd = do + rulespath <- rulesFilePathFromOpts copts + journalpath <- journalFilePathFromOpts copts + ej <- readJournalFiles Nothing rulespath (not $ ignore_assertions_ copts) journalpath + either error' (cmd uopts . journalApplyAliases (aliasesFromOpts copts)) ej runBrickUi :: UIOpts -> Journal -> IO () runBrickUi opts j = do