mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
ui, web: Enable --pivot and --anon in ui and web (#474)
This commit is contained in:
parent
e8aecb51ee
commit
13a6584440
@ -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
|
||||
|
@ -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 ()
|
||||
|
@ -19,6 +19,8 @@ module Hledger.Cli.Utils
|
||||
writeFileWithBackup,
|
||||
writeFileWithBackupIfChanged,
|
||||
readFileStrictly,
|
||||
pivotByOpts,
|
||||
anonymiseByOpts,
|
||||
Test(TestList),
|
||||
)
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user