simpler parsePatternArgs
This commit is contained in:
		
							parent
							
								
									7a4eb19b6d
								
							
						
					
					
						commit
						7637a40df7
					
				
							
								
								
									
										13
									
								
								Options.hs
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								Options.hs
									
									
									
									
									
								
							| @ -218,14 +218,13 @@ ledgerFilePathFromOpts opts = do | ||||
|   f <- if istimequery then myTimelogPath else myLedgerPath | ||||
|   return $ last $ f:(optValuesForConstructor File opts) | ||||
| 
 | ||||
| -- | Gather any pattern arguments into a list of account patterns and a | ||||
| -- list of description patterns. For now we interpret pattern arguments as | ||||
| -- | Gather filter pattern arguments into a list of account patterns and a | ||||
| -- list of description patterns. We interpret pattern arguments as | ||||
| -- follows: those prefixed with "desc:" are description patterns, all | ||||
| -- others are account patterns. Also patterns prefixed with "not:" are | ||||
| -- others are account patterns; also patterns prefixed with "not:" are | ||||
| -- negated. not: should come after desc: if both are used. | ||||
| -- This is different from ledger 2 and 3. | ||||
| parseAccountDescriptionArgs :: [Opt] -> [String] -> ([String],[String]) | ||||
| parseAccountDescriptionArgs opts args = (as, ds') | ||||
| parsePatternArgs :: [String] -> ([String],[String]) | ||||
| parsePatternArgs args = (as, ds') | ||||
|     where | ||||
|       descprefix = "desc:" | ||||
|       (ds, as) = partition (descprefix `isPrefixOf`) args | ||||
| @ -239,5 +238,5 @@ optsToIOArgs opts args t = (dateSpanFromOpts (localDay t) opts | ||||
|                          ,CostBasis `elem` opts | ||||
|                          ,apats | ||||
|                          ,dpats | ||||
|                          ) where (apats,dpats) = parseAccountDescriptionArgs [] args | ||||
|                          ) where (apats,dpats) = parsePatternArgs args | ||||
| 
 | ||||
|  | ||||
| @ -24,4 +24,4 @@ showLedgerTransactions opts args l = concatMap showLedgerTransaction $ filteredt | ||||
|                         filterRawLedgerTransactionsByAccount apats $  | ||||
|                         rawledger l | ||||
|       depth = depthFromOpts opts | ||||
|       (apats,_) = parseAccountDescriptionArgs opts args | ||||
|       (apats,_) = parsePatternArgs args | ||||
|  | ||||
| @ -45,7 +45,7 @@ showRegisterReport opts args l | ||||
|       (displayedts, _) = span (matchdisplayopt dopt) ts' | ||||
|       startbal = sumTransactions precedingts | ||||
|       matchapats t = matchpats apats $ taccount t | ||||
|       apats = fst $ parseAccountDescriptionArgs opts args | ||||
|       (apats,_) = parsePatternArgs args | ||||
|       matchdisplayopt Nothing t = True | ||||
|       matchdisplayopt (Just e) t = (fromparse $ parsewith datedisplayexpr e) t | ||||
|       dopt = displayFromOpts opts | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user