dev: cleanups
This commit is contained in:
parent
bfbef4bcbb
commit
db7783b16d
@ -332,9 +332,9 @@ readJournalFiles iopts@InputOpts{strict_, new_, new_save_} prefixedfiles = do
|
|||||||
when (new_ && new_save_) $ liftIO $ saveLatestDatesForFiles latestdatesforfiles
|
when (new_ && new_save_) $ liftIO $ saveLatestDatesForFiles latestdatesforfiles
|
||||||
return j
|
return j
|
||||||
|
|
||||||
-- The implementation of readJournalFiles, but with --new,
|
-- The implementation of readJournalFiles.
|
||||||
-- also returns the latest transaction date(s) read in each file.
|
-- With --new, it also returns the latest transaction date(s) read in each file
|
||||||
-- Used by the import command, to save those at the end.
|
-- (used by the import command).
|
||||||
readJournalFilesAndLatestDates :: InputOpts -> [PrefixedFilePath] -> ExceptT String IO (Journal, [LatestDatesForFile])
|
readJournalFilesAndLatestDates :: InputOpts -> [PrefixedFilePath] -> ExceptT String IO (Journal, [LatestDatesForFile])
|
||||||
readJournalFilesAndLatestDates iopts pfs = do
|
readJournalFilesAndLatestDates iopts pfs = do
|
||||||
(js, lastdates) <- unzip <$> mapM (readJournalFileAndLatestDates iopts) pfs
|
(js, lastdates) <- unzip <$> mapM (readJournalFileAndLatestDates iopts) pfs
|
||||||
|
|||||||
@ -54,10 +54,9 @@ reader sep = Reader
|
|||||||
-- but not good if it was loaded by a possibly long chain of include directives.
|
-- but not good if it was loaded by a possibly long chain of include directives.
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Parse and post-process a "Journal" from CSV data, or give an error.
|
-- | Parse and post-process a "Journal" from a CSV(/SSV/TSV/*SV) data file, or give an error.
|
||||||
-- This currently ignores the provided data, and reads it from the file path instead.
|
-- This currently ignores the provided input file handle, and reads from the data file itself,
|
||||||
-- This file path is normally the CSV(/SSV/TSV) data file, and a corresponding rules file is inferred.
|
-- inferring a corresponding rules file to help convert it.
|
||||||
-- But it can also be the rules file, in which case the corresponding data file is inferred.
|
|
||||||
-- This does not check balance assertions.
|
-- This does not check balance assertions.
|
||||||
parse :: SepFormat -> InputOpts -> FilePath -> Handle -> ExceptT String IO Journal
|
parse :: SepFormat -> InputOpts -> FilePath -> Handle -> ExceptT String IO Journal
|
||||||
parse sep iopts f h = do
|
parse sep iopts f h = do
|
||||||
@ -76,4 +75,3 @@ parse sep iopts f h = do
|
|||||||
|
|
||||||
tests_CsvReader = testGroup "CsvReader" [
|
tests_CsvReader = testGroup "CsvReader" [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -221,7 +221,8 @@ ansiFormatError = (<> sgrresetall) . ((sgrbrightred <> sgrbold) <>)
|
|||||||
-- | Show a message, with "Warning:" label, on stderr before returning the given value.
|
-- | Show a message, with "Warning:" label, on stderr before returning the given value.
|
||||||
-- Also do some ANSI styling of the first line when allowed (using unsafe IO).
|
-- Also do some ANSI styling of the first line when allowed (using unsafe IO).
|
||||||
-- Currently we use this very sparingly in hledger; we prefer to either quietly work,
|
-- Currently we use this very sparingly in hledger; we prefer to either quietly work,
|
||||||
-- or loudly raise an error. (Varying output can make scripting harder.)
|
-- or loudly raise an error. Varying output can make scripting harder,
|
||||||
|
-- but on stderr, it shouldn't cause much hassle.
|
||||||
warn :: String -> a -> a
|
warn :: String -> a -> a
|
||||||
warn msg = trace msg'
|
warn msg = trace msg'
|
||||||
where
|
where
|
||||||
|
|||||||
@ -12,12 +12,12 @@ where
|
|||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.List
|
import Data.List
|
||||||
import qualified Data.Text.IO as T
|
import qualified Data.Text.IO as T
|
||||||
|
import System.Console.CmdArgs.Explicit
|
||||||
|
import Text.Printf
|
||||||
|
|
||||||
import Hledger
|
import Hledger
|
||||||
import Hledger.Cli.CliOptions
|
import Hledger.Cli.CliOptions
|
||||||
import Hledger.Cli.Commands.Add (journalAddTransaction)
|
import Hledger.Cli.Commands.Add (journalAddTransaction)
|
||||||
-- import Hledger.Cli.Commands.Print (print')
|
|
||||||
import System.Console.CmdArgs.Explicit
|
|
||||||
import Text.Printf
|
|
||||||
|
|
||||||
importmode = hledgerCommandMode
|
importmode = hledgerCommandMode
|
||||||
$(embedFileRelative "Hledger/Cli/Commands/Import.txt")
|
$(embedFileRelative "Hledger/Cli/Commands/Import.txt")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user