mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 18:29:36 +03:00
check: also check "accounts"/"commodities" on demand
(cherry picked from commit 0c2bf54f2955e3a25fd0282acc42608f957abaea)
This commit is contained in:
parent
652deb04ee
commit
8306420b61
@ -45,6 +45,8 @@ module Hledger.Read.Common (
|
||||
parseAndFinaliseJournal,
|
||||
parseAndFinaliseJournal',
|
||||
journalFinalise,
|
||||
journalCheckAccountsDeclared,
|
||||
journalCheckCommoditiesDeclared,
|
||||
journalCheckPayeesDeclared,
|
||||
setYear,
|
||||
getYear,
|
||||
|
@ -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).
|
||||
|
@ -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 <https://github.com/simonmichael/hledger/tree/master/bin>:
|
||||
|
||||
- **hledger-check-tagfiles** - all tag values containing / (a forward slash) exist as file paths
|
||||
|
Loading…
Reference in New Issue
Block a user