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 _ ('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 _ ('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 _ ('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 _ ('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 _ ('t':'a':'g':':':s) = Left $ Tag n v where (n,v) = parseTag s
 | 
				
			||||||
parseQueryTerm _ "" = Left $ Any
 | 
					parseQueryTerm _ "" = Left $ Any
 | 
				
			||||||
 | 
				
			|||||||
@ -162,7 +162,10 @@ rawOptsToReportOpts rawopts = checkReportOpts <$> do
 | 
				
			|||||||
-- | Do extra validation of opts, raising an error if there is trouble.
 | 
					-- | Do extra validation of opts, raising an error if there is trouble.
 | 
				
			||||||
checkReportOpts :: ReportOpts -> ReportOpts
 | 
					checkReportOpts :: ReportOpts -> ReportOpts
 | 
				
			||||||
checkReportOpts ropts@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 -> AccountListMode
 | 
				
			||||||
accountlistmodeopt rawopts =
 | 
					accountlistmodeopt rawopts =
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user