lib: Hledger.Read: more ways to read the default journal
defaultJournalWith, defaultJournalSafely, defaultJournalSafelyWith
This commit is contained in:
parent
f39b34184e
commit
255e79c550
@ -89,6 +89,9 @@ module Hledger.Read (
|
|||||||
-- * Journal files
|
-- * Journal files
|
||||||
PrefixedFilePath,
|
PrefixedFilePath,
|
||||||
defaultJournal,
|
defaultJournal,
|
||||||
|
defaultJournalWith,
|
||||||
|
defaultJournalSafely,
|
||||||
|
defaultJournalSafelyWith,
|
||||||
defaultJournalPath,
|
defaultJournalPath,
|
||||||
requireJournalFileExists,
|
requireJournalFileExists,
|
||||||
ensureJournalFileExists,
|
ensureJournalFileExists,
|
||||||
@ -175,9 +178,25 @@ journalEnvVar = "LEDGER_FILE"
|
|||||||
journalEnvVar2 = "LEDGER"
|
journalEnvVar2 = "LEDGER"
|
||||||
journalDefaultFilename = ".hledger.journal"
|
journalDefaultFilename = ".hledger.journal"
|
||||||
|
|
||||||
-- | Read the default journal file specified by the environment, or raise an error.
|
-- | Read the default journal file specified by the environment,
|
||||||
|
-- with default input options, or raise an error.
|
||||||
defaultJournal :: IO Journal
|
defaultJournal :: IO Journal
|
||||||
defaultJournal = defaultJournalPath >>= runExceptT . readJournalFile definputopts >>= either error' return -- PARTIAL:
|
defaultJournal = defaultJournalSafely >>= either error' return -- PARTIAL:
|
||||||
|
|
||||||
|
-- | Read the default journal file specified by the environment,
|
||||||
|
-- with the given input options, or raise an error.
|
||||||
|
defaultJournalWith :: InputOpts -> IO Journal
|
||||||
|
defaultJournalWith iopts = defaultJournalSafelyWith iopts >>= either error' return -- PARTIAL:
|
||||||
|
|
||||||
|
-- | Read the default journal file specified by the environment,
|
||||||
|
-- with default input options, or return an error message.
|
||||||
|
defaultJournalSafely :: IO (Either String Journal)
|
||||||
|
defaultJournalSafely = defaultJournalSafelyWith definputopts
|
||||||
|
|
||||||
|
-- | Read the default journal file specified by the environment,
|
||||||
|
-- with the given input options, or return an error message.
|
||||||
|
defaultJournalSafelyWith :: InputOpts -> IO (Either String Journal)
|
||||||
|
defaultJournalSafelyWith iopts = defaultJournalPath >>= runExceptT . readJournalFile iopts
|
||||||
|
|
||||||
-- | Get the default journal file path specified by the environment.
|
-- | Get the default journal file path specified by the environment.
|
||||||
-- Like ledger, we look first for the LEDGER_FILE environment
|
-- Like ledger, we look first for the LEDGER_FILE environment
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user