dev: cleanups

This commit is contained in:
Simon Michael 2025-08-14 12:17:18 +01:00
parent bfbef4bcbb
commit db7783b16d
4 changed files with 11 additions and 12 deletions

View File

@ -332,9 +332,9 @@ readJournalFiles iopts@InputOpts{strict_, new_, new_save_} prefixedfiles = do
when (new_ && new_save_) $ liftIO $ saveLatestDatesForFiles latestdatesforfiles
return j
-- The implementation of readJournalFiles, but with --new,
-- also returns the latest transaction date(s) read in each file.
-- Used by the import command, to save those at the end.
-- The implementation of readJournalFiles.
-- With --new, it also returns the latest transaction date(s) read in each file
-- (used by the import command).
readJournalFilesAndLatestDates :: InputOpts -> [PrefixedFilePath] -> ExceptT String IO (Journal, [LatestDatesForFile])
readJournalFilesAndLatestDates iopts pfs = do
(js, lastdates) <- unzip <$> mapM (readJournalFileAndLatestDates iopts) pfs

View File

@ -54,10 +54,9 @@ reader sep = Reader
-- 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.
-- This currently ignores the provided data, and reads it from the file path instead.
-- This file path is normally the CSV(/SSV/TSV) data file, and a corresponding rules file is inferred.
-- But it can also be the rules file, in which case the corresponding data file is inferred.
-- | Parse and post-process a "Journal" from a CSV(/SSV/TSV/*SV) data file, or give an error.
-- This currently ignores the provided input file handle, and reads from the data file itself,
-- inferring a corresponding rules file to help convert it.
-- This does not check balance assertions.
parse :: SepFormat -> InputOpts -> FilePath -> Handle -> ExceptT String IO Journal
parse sep iopts f h = do
@ -76,4 +75,3 @@ parse sep iopts f h = do
tests_CsvReader = testGroup "CsvReader" [
]

View File

@ -221,7 +221,8 @@ ansiFormatError = (<> sgrresetall) . ((sgrbrightred <> sgrbold) <>)
-- | 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).
-- 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 msg = trace msg'
where

View File

@ -12,12 +12,12 @@ where
import Control.Monad
import Data.List
import qualified Data.Text.IO as T
import System.Console.CmdArgs.Explicit
import Text.Printf
import Hledger
import Hledger.Cli.CliOptions
import Hledger.Cli.Commands.Add (journalAddTransaction)
-- import Hledger.Cli.Commands.Print (print')
import System.Console.CmdArgs.Explicit
import Text.Printf
importmode = hledgerCommandMode
$(embedFileRelative "Hledger/Cli/Commands/Import.txt")