From f8e781462dc590dfba4370f0f353e0d77f784b8d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 29 Dec 2017 16:53:37 -0800 Subject: [PATCH] ui, web: use/support new -V, --forecast, --auto --- hledger-ui/Hledger/UI/Main.hs | 13 ++++++++----- hledger-web/Hledger/Web/Main.hs | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index 1f43f6666..72038d264 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -71,15 +71,18 @@ main = do | "binary-filename" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname) | otherwise = withJournalDoUICommand opts runBrickUi --- XXX withJournalDo specialised for UIOpts +-- TODO fix nasty duplication of withJournalDo withJournalDoUICommand :: UIOpts -> (UIOpts -> Journal -> IO ()) -> IO () withJournalDoUICommand uopts@UIOpts{cliopts_=copts} cmd = do journalpath <- journalFilePathFromOpts copts ej <- readJournalFilesWithOpts (inputopts_ copts) journalpath - let fn = cmd uopts . - pivotByOpts copts . - anonymiseByOpts copts . - journalApplyAliases (aliasesFromOpts copts) + let fn = cmd uopts + . pivotByOpts copts + . anonymiseByOpts copts + . journalApplyAliases (aliasesFromOpts copts) + <=< journalApplyValue (reportopts_ copts) + <=< journalAddForecast copts + . generateAutomaticPostings (reportopts_ copts) either error' fn ej runBrickUi :: UIOpts -> Journal -> IO () diff --git a/hledger-web/Hledger/Web/Main.hs b/hledger-web/Hledger/Web/Main.hs index e121f9c95..28099eb4d 100644 --- a/hledger-web/Hledger/Web/Main.hs +++ b/hledger-web/Hledger/Web/Main.hs @@ -22,7 +22,7 @@ import Network.Wai.Handler.Launch (runHostPortUrl) #if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>)) #endif -import Control.Monad (when) +import Control.Monad import Data.Text (pack) import System.Exit (exitSuccess) import System.IO (hFlush, stdout) @@ -59,10 +59,13 @@ withJournalDo' opts@WebOpts {cliopts_ = cliopts} cmd = do -- Also we may be writing to this file. Just disallow it. when (f == "-") $ error' "hledger-web doesn't support -f -, please specify a file path" - let fn = cmd opts . - pivotByOpts cliopts . - anonymiseByOpts cliopts . - journalApplyAliases (aliasesFromOpts cliopts) + let fn = cmd opts + . pivotByOpts cliopts + . anonymiseByOpts cliopts + . journalApplyAliases (aliasesFromOpts cliopts) + <=< journalApplyValue (reportopts_ cliopts) + <=< journalAddForecast cliopts + . generateAutomaticPostings (reportopts_ cliopts) readJournalFile Nothing Nothing True f >>= either error' fn -- | The web command.