return non-zero exit code on parse failure

This commit is contained in:
Simon Michael 2009-11-25 19:56:51 +00:00
parent b683ca8e40
commit ef3b5ab98d
2 changed files with 6 additions and 5 deletions

View File

@ -33,7 +33,9 @@ withLedgerDo opts args cmdname cmd = do
t <- getCurrentLocalTime t <- getCurrentLocalTime
tc <- getClockTime tc <- getClockTime
let go = cmd opts args . filterAndCacheLedgerWithOpts opts args t rawtext . (\rl -> rl{filepath=f,filereadtime=tc}) let go = cmd opts args . filterAndCacheLedgerWithOpts opts args t rawtext . (\rl -> rl{filepath=f,filereadtime=tc})
if creating then go rawLedgerEmpty else (runErrorT . parseLedgerFile t) f >>= either (hPutStrLn stderr) go if creating then go rawLedgerEmpty else (runErrorT . parseLedgerFile t) f
>>= flip either go
(\e -> hPutStrLn stderr e >> exitWith (ExitFailure 1))
-- | Get a Ledger from the given string and options, or raise an error. -- | Get a Ledger from the given string and options, or raise an error.
ledgerFromStringWithOpts :: [Opt] -> [String] -> LocalTime -> String -> IO Ledger ledgerFromStringWithOpts :: [Opt] -> [String] -> LocalTime -> String -> IO Ledger

View File

@ -1,4 +1,3 @@
# shouldn't exit code be 1 ?
-f - register -f - register
<<< <<<
2009/1/1 a 2009/1/1 a
@ -9,8 +8,8 @@
unexpected end of input unexpected end of input
could not balance this transaction, amounts do not add up to zero: could not balance this transaction, amounts do not add up to zero:
2009/01/01 a 2009/01/01 a
b 1.1 b 1.1
c -1 c -1
>>>= 0 >>>= 1