refactor: move readJournal'
This commit is contained in:
parent
197f35cb5b
commit
db4d853a3f
@ -12,6 +12,7 @@ module Hledger.Read (
|
|||||||
defaultJournalPath,
|
defaultJournalPath,
|
||||||
defaultJournal,
|
defaultJournal,
|
||||||
readJournal,
|
readJournal,
|
||||||
|
readJournal',
|
||||||
readJournalFile,
|
readJournalFile,
|
||||||
requireJournalFileExists,
|
requireJournalFileExists,
|
||||||
ensureJournalFileExists,
|
ensureJournalFileExists,
|
||||||
@ -89,6 +90,10 @@ readerForFormat s | null rs = Nothing
|
|||||||
where
|
where
|
||||||
rs = filter ((s==).rFormat) readers :: [Reader]
|
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
|
-- | Read a Journal from this string or give an error message, using the
|
||||||
-- specified data format or trying all known formats. A CSV conversion
|
-- specified data format or trying all known formats. A CSV conversion
|
||||||
-- rules file may be specified for better conversion of that format,
|
-- rules file may be specified for better conversion of that format,
|
||||||
|
|||||||
@ -32,7 +32,6 @@ import Prelude hiding (putStr, putStrLn, appendFile)
|
|||||||
import Hledger.Utils.UTF8IOCompat (putStr, putStrLn, appendFile)
|
import Hledger.Utils.UTF8IOCompat (putStr, putStrLn, appendFile)
|
||||||
import Hledger.Cli.Options
|
import Hledger.Cli.Options
|
||||||
import Hledger.Cli.Register (postingsReportAsText)
|
import Hledger.Cli.Register (postingsReportAsText)
|
||||||
import Hledger.Cli.Utils
|
|
||||||
|
|
||||||
|
|
||||||
{- | Information used as the basis for suggested account names, amounts,
|
{- | Information used as the basis for suggested account names, amounts,
|
||||||
|
|||||||
@ -8,7 +8,6 @@ Hledger.Utils.
|
|||||||
module Hledger.Cli.Utils
|
module Hledger.Cli.Utils
|
||||||
(
|
(
|
||||||
withJournalDo,
|
withJournalDo,
|
||||||
readJournal',
|
|
||||||
journalReload,
|
journalReload,
|
||||||
journalReloadIfChanged,
|
journalReloadIfChanged,
|
||||||
journalFileIsNewer,
|
journalFileIsNewer,
|
||||||
@ -55,10 +54,6 @@ withJournalDo opts cmd = do
|
|||||||
-- readJournalWithOpts :: CliOpts -> String -> IO Journal
|
-- readJournalWithOpts :: CliOpts -> String -> IO Journal
|
||||||
-- readJournalWithOpts opts s = readJournal Nothing Nothing Nothing s >>= either error' return
|
-- 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.
|
-- | Re-read a journal from its data file, or return an error string.
|
||||||
journalReload :: Journal -> IO (Either String Journal)
|
journalReload :: Journal -> IO (Either String Journal)
|
||||||
journalReload j = readJournalFile Nothing Nothing $ journalFilePath j
|
journalReload j = readJournalFile Nothing Nothing $ journalFilePath j
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user