mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
validate --depth/depth:'s argument is positive
This commit is contained in:
parent
4dd1e9c725
commit
0d02262463
@ -256,7 +256,11 @@ parseQueryTerm _ ('s':'t':'a':'t':'u':'s':':':s) =
|
||||
parseQueryTerm _ ('r':'e':'a':'l':':':s) = Left $ Real $ parseBool s || null s
|
||||
parseQueryTerm _ ('a':'m':'t':':':s) = Left $ Amt ord q where (ord, q) = parseAmountQueryTerm s
|
||||
parseQueryTerm _ ('e':'m':'p':'t':'y':':':s) = Left $ Empty $ parseBool s
|
||||
parseQueryTerm _ ('d':'e':'p':'t':'h':':':s) = Left $ Depth $ readDef 0 s
|
||||
parseQueryTerm _ ('d':'e':'p':'t':'h':':':s)
|
||||
| n >= 0 = Left $ Depth n
|
||||
| otherwise = error' "depth: should have a positive number"
|
||||
where n = readDef 0 s
|
||||
|
||||
parseQueryTerm _ ('c':'u':'r':':':s) = Left $ Sym s -- support cur: as an alias
|
||||
parseQueryTerm _ ('t':'a':'g':':':s) = Left $ Tag n v where (n,v) = parseTag s
|
||||
parseQueryTerm _ "" = Left $ Any
|
||||
|
@ -162,7 +162,10 @@ rawOptsToReportOpts rawopts = checkReportOpts <$> do
|
||||
-- | Do extra validation of opts, raising an error if there is trouble.
|
||||
checkReportOpts :: ReportOpts -> ReportOpts
|
||||
checkReportOpts ropts@ReportOpts{..} =
|
||||
ropts
|
||||
either optserror (const ropts) $ do
|
||||
case depth_ of
|
||||
Just d | d < 0 -> Left "--depth should have a positive number"
|
||||
_ -> Right ()
|
||||
|
||||
accountlistmodeopt :: RawOpts -> AccountListMode
|
||||
accountlistmodeopt rawopts =
|
||||
|
Loading…
Reference in New Issue
Block a user