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, | ||||||
|   parseAndFinaliseJournal', |   parseAndFinaliseJournal', | ||||||
|   journalFinalise, |   journalFinalise, | ||||||
|  |   journalCheckAccountsDeclared, | ||||||
|  |   journalCheckCommoditiesDeclared, | ||||||
|   journalCheckPayeesDeclared, |   journalCheckPayeesDeclared, | ||||||
|   setYear, |   setYear, | ||||||
|   getYear, |   getYear, | ||||||
|  | |||||||
| @ -45,7 +45,9 @@ check copts@CliOpts{rawopts_} j = do | |||||||
| -- (Currently, just the optional checks that only the check command | -- (Currently, just the optional checks that only the check command | ||||||
| -- can do; not the checks done by default or with --strict.) | -- can do; not the checks done by default or with --strict.) | ||||||
| data Check = | data Check = | ||||||
|     Ordereddates |     Accounts | ||||||
|  |   | Commodities | ||||||
|  |   | Ordereddates | ||||||
|   | Payees |   | Payees | ||||||
|   | Uniqueleafnames |   | Uniqueleafnames | ||||||
|   deriving (Read,Show,Eq) |   deriving (Read,Show,Eq) | ||||||
| @ -74,12 +76,17 @@ parseCheckArgument s = | |||||||
| runCheck :: CliOpts -> Journal -> (Check,[String]) -> IO () | runCheck :: CliOpts -> Journal -> (Check,[String]) -> IO () | ||||||
| runCheck copts@CliOpts{rawopts_} j (check,args) =  | runCheck copts@CliOpts{rawopts_} j (check,args) =  | ||||||
|   case check of |   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 |     Uniqueleafnames -> checkdupes copts' j | ||||||
|     Payees          -> |  | ||||||
|       case journalCheckPayeesDeclared j of |  | ||||||
|         Right () -> return () |  | ||||||
|         Left err -> hPutStrLn stderr ("Error: "++err) >> exitFailure |  | ||||||
|   where |   where | ||||||
|     -- Hack: append the provided args to the raw opts, |     -- Hack: append the provided args to the raw opts, | ||||||
|     -- in case the check can use them (like checkdates --unique).  |     -- in case the check can use them (like checkdates --unique).  | ||||||
|  | |||||||
| @ -21,7 +21,8 @@ Here are the checks currently available: | |||||||
| 
 | 
 | ||||||
| ### Basic checks | ### 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  | - **parseable** - data files are well-formed and can be  | ||||||
|   [successfully parsed](hledger.html#input-files) |   [successfully parsed](hledger.html#input-files) | ||||||
| @ -35,8 +36,8 @@ These are always run by this command and other commands: | |||||||
| 
 | 
 | ||||||
| ### Strict checks | ### Strict checks | ||||||
| 
 | 
 | ||||||
| These are always run by this and other commands when `-s`/`--strict` is used | These additional checks are run when the `-s`/`--strict` ([strict mode]) flag is used. | ||||||
| ([strict mode]): | They can also be run by specifying their names as arguments to `check`: | ||||||
| 
 | 
 | ||||||
| - **accounts** - all account names used by transactions  | - **accounts** - all account names used by transactions  | ||||||
|   [have been declared](hledger.html#account-error-checking) |   [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 | ### 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) | - **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 | ### 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>: | [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 | - **hledger-check-tagfiles** - all tag values containing / (a forward slash) exist as file paths | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user