From 4927711490e9817767d81213b3bd0fb2e0de402e Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 10 Jun 2016 16:18:57 -0700 Subject: [PATCH] lib: when reloading a journal, keep aliases and pivot in effect --- hledger/Hledger/Cli/Utils.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hledger/Hledger/Cli/Utils.hs b/hledger/Hledger/Cli/Utils.hs index 19977a424..24f5b5cd7 100644 --- a/hledger/Hledger/Cli/Utils.hs +++ b/hledger/Hledger/Cli/Utils.hs @@ -62,8 +62,8 @@ import Hledger.Read import Hledger.Utils --- | Parse the user's specified journal file and run a hledger command on --- it, or throw an error. +-- | Parse the user's specified journal file, maybe apply some transformations +-- (aliases, pivot) and run a hledger command on it, or throw an error. withJournalDo :: CliOpts -> (CliOpts -> Journal -> IO ()) -> IO () withJournalDo opts cmd = do -- We kludgily read the file before parsing to grab the full text, unless @@ -101,13 +101,15 @@ writeOutput opts s = do -- readJournalWithOpts :: CliOpts -> String -> IO Journal -- readJournalWithOpts opts s = readJournal Nothing Nothing Nothing s >>= either error' return --- | Re-read the journal file(s) specified by options, or return an error string. +-- | Re-read the journal file(s) specified by options and maybe apply some +-- transformations (aliases, pivot), or return an error string. -- Reads the full journal, without filtering. journalReload :: CliOpts -> IO (Either String Journal) journalReload opts = do rulespath <- rulesFilePathFromOpts opts journalpaths <- journalFilePathFromOpts opts - readJournalFiles Nothing rulespath (not $ ignore_assertions_ opts) journalpaths + ((pivotByOpts opts . journalApplyAliases (aliasesFromOpts opts)) <$>) <$> + readJournalFiles Nothing rulespath (not $ ignore_assertions_ opts) journalpaths -- | Re-read the option-specified journal file(s), but only if any of -- them has changed since last read. (If the file is standard input,