diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 6de103fdd..4bd138267 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -45,6 +45,8 @@ module Hledger.Read.Common ( parseAndFinaliseJournal, parseAndFinaliseJournal', journalFinalise, + journalCheckAccountsDeclared, + journalCheckCommoditiesDeclared, journalCheckPayeesDeclared, setYear, getYear, diff --git a/hledger/Hledger/Cli/Commands/Check.hs b/hledger/Hledger/Cli/Commands/Check.hs index d1884c57a..b79fefa6a 100644 --- a/hledger/Hledger/Cli/Commands/Check.hs +++ b/hledger/Hledger/Cli/Commands/Check.hs @@ -45,7 +45,9 @@ check copts@CliOpts{rawopts_} j = do -- (Currently, just the optional checks that only the check command -- can do; not the checks done by default or with --strict.) data Check = - Ordereddates + Accounts + | Commodities + | Ordereddates | Payees | Uniqueleafnames deriving (Read,Show,Eq) @@ -74,12 +76,17 @@ parseCheckArgument s = runCheck :: CliOpts -> Journal -> (Check,[String]) -> IO () runCheck copts@CliOpts{rawopts_} j (check,args) = case check of - Ordereddates -> checkdates copts' j + Accounts -> case journalCheckAccountsDeclared j of + Right () -> return () + Left err -> hPutStrLn stderr ("Error: "++err) >> exitFailure + Commodities -> case journalCheckCommoditiesDeclared j of + Right () -> return () + Left err -> hPutStrLn stderr ("Error: "++err) >> exitFailure + Ordereddates -> checkdates copts' j + Payees -> case journalCheckPayeesDeclared j of + Right () -> return () + Left err -> hPutStrLn stderr ("Error: "++err) >> exitFailure Uniqueleafnames -> checkdupes copts' j - Payees -> - case journalCheckPayeesDeclared j of - Right () -> return () - Left err -> hPutStrLn stderr ("Error: "++err) >> exitFailure where -- Hack: append the provided args to the raw opts, -- in case the check can use them (like checkdates --unique). diff --git a/hledger/Hledger/Cli/Commands/Check.md b/hledger/Hledger/Cli/Commands/Check.md index 2dc7cee6a..23c9d20d7 100644 --- a/hledger/Hledger/Cli/Commands/Check.md +++ b/hledger/Hledger/Cli/Commands/Check.md @@ -21,7 +21,8 @@ Here are the checks currently available: ### Basic checks -These are always run by this command and other commands: +These checks are always run automatically, by (almost) all hledger commands, +including `check`: - **parseable** - data files are well-formed and can be [successfully parsed](hledger.html#input-files) @@ -35,8 +36,8 @@ These are always run by this command and other commands: ### Strict checks -These are always run by this and other commands when `-s`/`--strict` is used -([strict mode]): +These additional checks are run when the `-s`/`--strict` ([strict mode]) flag is used. +They can also be run by specifying their names as arguments to `check`: - **accounts** - all account names used by transactions [have been declared](hledger.html#account-error-checking) @@ -46,7 +47,7 @@ These are always run by this and other commands when `-s`/`--strict` is used ### Other checks -These checks can be run by specifying their names as arguments to the check command: +These checks can be run only by specifying their names as arguments to `check`: - **ordereddates** - transactions are ordered by date (similar to the old `check-dates` command) @@ -56,7 +57,7 @@ These checks can be run by specifying their names as arguments to the check comm ### Add-on checks -Some checks are not yet integrated with this command, but are available as +These checks are not yet integrated with `check`, but are available as [add-on commands] in : - **hledger-check-tagfiles** - all tag values containing / (a forward slash) exist as file paths