diff --git a/hledger-lib/Hledger/Read.hs b/hledger-lib/Hledger/Read.hs index 59654c1f2..4ac92fcde 100644 --- a/hledger-lib/Hledger/Read.hs +++ b/hledger-lib/Hledger/Read.hs @@ -12,6 +12,7 @@ module Hledger.Read ( defaultJournalPath, defaultJournal, readJournal, + readJournal', readJournalFile, requireJournalFileExists, ensureJournalFileExists, @@ -89,6 +90,10 @@ readerForFormat s | null rs = Nothing where rs = filter ((s==).rFormat) readers :: [Reader] +-- | Read a journal from the given string, trying all known formats, or simply throw an error. +readJournal' :: String -> IO Journal +readJournal' s = readJournal Nothing Nothing Nothing s >>= either error' return + -- | Read a Journal from this string or give an error message, using the -- specified data format or trying all known formats. A CSV conversion -- rules file may be specified for better conversion of that format, diff --git a/hledger/Hledger/Cli/Add.hs b/hledger/Hledger/Cli/Add.hs index ed729cdbe..31a3440c6 100644 --- a/hledger/Hledger/Cli/Add.hs +++ b/hledger/Hledger/Cli/Add.hs @@ -32,7 +32,6 @@ import Prelude hiding (putStr, putStrLn, appendFile) import Hledger.Utils.UTF8IOCompat (putStr, putStrLn, appendFile) import Hledger.Cli.Options import Hledger.Cli.Register (postingsReportAsText) -import Hledger.Cli.Utils {- | Information used as the basis for suggested account names, amounts, diff --git a/hledger/Hledger/Cli/Utils.hs b/hledger/Hledger/Cli/Utils.hs index b299e2a5e..0956be600 100644 --- a/hledger/Hledger/Cli/Utils.hs +++ b/hledger/Hledger/Cli/Utils.hs @@ -8,7 +8,6 @@ Hledger.Utils. module Hledger.Cli.Utils ( withJournalDo, - readJournal', journalReload, journalReloadIfChanged, journalFileIsNewer, @@ -55,10 +54,6 @@ withJournalDo opts cmd = do -- readJournalWithOpts :: CliOpts -> String -> IO Journal -- readJournalWithOpts opts s = readJournal Nothing Nothing Nothing s >>= either error' return --- | Get a journal from the given string, or throw an error. -readJournal' :: String -> IO Journal -readJournal' s = readJournal Nothing Nothing Nothing s >>= either error' return - -- | Re-read a journal from its data file, or return an error string. journalReload :: Journal -> IO (Either String Journal) journalReload j = readJournalFile Nothing Nothing $ journalFilePath j