misc cleanup
This commit is contained in:
		
							parent
							
								
									4d49177117
								
							
						
					
					
						commit
						3e1a615dbf
					
				| @ -507,7 +507,7 @@ smartdate = do | ||||
|              ,try d | ||||
|              ,try month | ||||
|              ,try mon | ||||
|              ,try parsetoday | ||||
|              ,try today' | ||||
|              ,try yesterday | ||||
|              ,try tomorrow | ||||
| --              ,try thiswhatever | ||||
| @ -516,15 +516,15 @@ smartdate = do | ||||
|             ] | ||||
|   return $ (y,m,d) | ||||
| 
 | ||||
| datesep = oneOf "/-." | ||||
| datesepchar = oneOf "/-." | ||||
| 
 | ||||
| ymd :: Parser (String,String,String) | ||||
| ymd = do | ||||
|   y <- many1 digit | ||||
|   datesep | ||||
|   datesepchar | ||||
|   m <- many1 digit | ||||
|   guard (read m <= 12) | ||||
|   datesep | ||||
|   datesepchar | ||||
|   d <- many1 digit | ||||
|   guard (read d <= 31) | ||||
|   return (y,m,d) | ||||
| @ -533,7 +533,7 @@ ym :: Parser (String,String,String) | ||||
| ym = do | ||||
|   y <- many1 digit | ||||
|   guard (read y > 12) | ||||
|   datesep | ||||
|   datesepchar | ||||
|   m <- many1 digit | ||||
|   guard (read m <= 12) | ||||
|   return (y,m,"1") | ||||
| @ -555,7 +555,7 @@ md :: Parser (String,String,String) | ||||
| md = do | ||||
|   m <- many1 digit | ||||
|   guard (read m <= 12) | ||||
|   datesep | ||||
|   datesepchar | ||||
|   d <- many1 digit | ||||
|   guard (read d <= 31) | ||||
|   return ("",m,d) | ||||
| @ -577,10 +577,9 @@ mon = do | ||||
|   let i = maybe 0 (+1) $ (map toLower m) `elemIndex` mons | ||||
|   return ("",show i,"1") | ||||
| 
 | ||||
| parsetoday = string "today" >> return ("","","today") | ||||
| today'    = string "today"     >> return ("","","today") | ||||
| yesterday = string "yesterday" >> return ("","","yesterday") | ||||
| tomorrow = string "tomorrow" >> return ("","","tomorrow") | ||||
| 
 | ||||
| tomorrow  = string "tomorrow"  >> return ("","","tomorrow") | ||||
| 
 | ||||
| 
 | ||||
| type TransactionMatcher = Transaction -> Bool | ||||
|  | ||||
							
								
								
									
										21
									
								
								Options.hs
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								Options.hs
									
									
									
									
									
								
							| @ -9,12 +9,8 @@ import Ledger.Dates | ||||
| import Ledger.Utils | ||||
| 
 | ||||
| 
 | ||||
| usage = usageInfo usagehdr options ++ usageftr | ||||
| 
 | ||||
| negativePatternChar opts | ||||
|     | OptionsAnywhere `elem` opts = '^' | ||||
|     | otherwise = '-' | ||||
| 
 | ||||
| defaultfile = "~/.ledger" | ||||
| fileenvvar  = "LEDGER" | ||||
| usagehdr    = "Usage: hledger [OPTS] COMMAND [ACCTPATTERNS] [-- DESCPATTERNS]\n" ++ | ||||
|               "\n" ++ | ||||
|               "Options (before command, unless using --options-anywhere):" | ||||
| @ -31,8 +27,7 @@ usageftr    = "\n" ++ | ||||
|               "\n" ++ | ||||
|               "Also: hledger [-v] test [TESTPATTERNS] to run self-tests.\n" ++ | ||||
|               "\n" | ||||
| defaultfile = "~/.ledger" | ||||
| fileenvvar  = "LEDGER" | ||||
| usage = usageInfo usagehdr options ++ usageftr | ||||
| 
 | ||||
| -- | Command-line options we accept. | ||||
| options :: [OptDescr Opt] | ||||
| @ -203,14 +198,10 @@ parseAccountDescriptionArgs opts args = (as, ds') | ||||
|     where (as, ds) = break (==patseparator) args | ||||
|           ds' = dropWhile (==patseparator) ds | ||||
|           patseparator = replicate 2 negchar | ||||
|           negchar = negativePatternChar opts | ||||
|           negchar | ||||
|               | OptionsAnywhere `elem` opts = '^' | ||||
|               | otherwise = '-' | ||||
| 
 | ||||
| -- testoptions RequireOrder ["foo","-v"] | ||||
| -- testoptions Permute ["foo","-v"] | ||||
| -- testoptions (ReturnInOrder Arg) ["foo","-v"] | ||||
| -- testoptions Permute ["foo","--","-v"] | ||||
| -- testoptions Permute ["-?o","--name","bar","--na=baz"] | ||||
| -- testoptions Permute ["--ver","foo"] | ||||
| testoptions order cmdline = putStr $  | ||||
|     case getOpt order options cmdline of | ||||
|       (o,n,[]  ) -> "options=" ++ show o ++ "  args=" ++ show n | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user