ui, web: Enable --pivot and --anon in ui and web (#474)

This commit is contained in:
Jakub Zárybnický 2017-08-29 15:18:36 +02:00 committed by Simon Michael
parent e8aecb51ee
commit 13a6584440
3 changed files with 14 additions and 5 deletions

View File

@ -77,7 +77,11 @@ 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
let fn = cmd uopts .
pivotByOpts copts .
anonymiseByOpts copts .
journalApplyAliases (aliasesFromOpts copts)
either error' fn ej
runBrickUi :: UIOpts -> Journal -> IO ()
runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} j = do

View File

@ -51,16 +51,19 @@ runWith opts
withJournalDo' opts web
withJournalDo' :: WebOpts -> (WebOpts -> Journal -> IO ()) -> IO ()
withJournalDo' opts cmd = do
f <- head `fmap` journalFilePathFromOpts (cliopts_ opts) -- XXX head should be safe for now
withJournalDo' opts@WebOpts {cliopts_ = cliopts} cmd = do
f <- head `fmap` journalFilePathFromOpts cliopts -- XXX head should be safe for now
-- https://github.com/simonmichael/hledger/issues/202
-- -f- gives [Error#yesod-core] <stdin>: hGetContents: illegal operation (handle is closed) for some reason
-- 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"
readJournalFile Nothing Nothing True f >>=
either error' (cmd opts . journalApplyAliases (aliasesFromOpts $ cliopts_ opts))
let fn = cmd opts .
pivotByOpts cliopts .
anonymiseByOpts cliopts .
journalApplyAliases (aliasesFromOpts cliopts)
readJournalFile Nothing Nothing True f >>= either error' fn
-- | The web command.
web :: WebOpts -> Journal -> IO ()

View File

@ -19,6 +19,8 @@ module Hledger.Cli.Utils
writeFileWithBackup,
writeFileWithBackupIfChanged,
readFileStrictly,
pivotByOpts,
anonymiseByOpts,
Test(TestList),
)
where