Option: cabal test and hlint warnings
This commit is contained in:
		
							parent
							
								
									f5d2d9b766
								
							
						
					
					
						commit
						39479638e3
					
				| @ -98,20 +98,20 @@ reportflags :: [Flag RawOpts] | |||||||
| reportflags = [ | reportflags = [ | ||||||
|   flagReq  ["begin","b"]     (\s opts -> Right $ setopt "begin" s opts) "DATE" "include postings/txns on or after this date" |   flagReq  ["begin","b"]     (\s opts -> Right $ setopt "begin" s opts) "DATE" "include postings/txns on or after this date" | ||||||
|  ,flagReq  ["end","e"]       (\s opts -> Right $ setopt "end" s opts) "DATE" "include postings/txns before this date" |  ,flagReq  ["end","e"]       (\s opts -> Right $ setopt "end" s opts) "DATE" "include postings/txns before this date" | ||||||
|  ,flagNone ["daily","D"]     (\opts -> setboolopt "daily" opts) "multiperiod/multicolumn report by day" |  ,flagNone ["daily","D"]     (setboolopt "daily") "multiperiod/multicolumn report by day" | ||||||
|  ,flagNone ["weekly","W"]    (\opts -> setboolopt "weekly" opts) "multiperiod/multicolumn report by week" |  ,flagNone ["weekly","W"]    (setboolopt "weekly") "multiperiod/multicolumn report by week" | ||||||
|  ,flagNone ["monthly","M"]   (\opts -> setboolopt "monthly" opts) "multiperiod/multicolumn report by month" |  ,flagNone ["monthly","M"]   (setboolopt "monthly") "multiperiod/multicolumn report by month" | ||||||
|  ,flagNone ["quarterly","Q"] (\opts -> setboolopt "quarterly" opts) "multiperiod/multicolumn report by quarter" |  ,flagNone ["quarterly","Q"] (setboolopt "quarterly") "multiperiod/multicolumn report by quarter" | ||||||
|  ,flagNone ["yearly","Y"]    (\opts -> setboolopt "yearly" opts) "multiperiod/multicolumn report by year" |  ,flagNone ["yearly","Y"]    (setboolopt "yearly") "multiperiod/multicolumn report by year" | ||||||
|  ,flagReq  ["period","p"]    (\s opts -> Right $ setopt "period" s opts) "PERIODEXP" "set start date, end date, and/or reporting interval all at once (overrides the flags above)" |  ,flagReq  ["period","p"]    (\s opts -> Right $ setopt "period" s opts) "PERIODEXP" "set start date, end date, and/or reporting interval all at once (overrides the flags above)" | ||||||
|  ,flagNone ["date2","aux-date"] (\opts -> setboolopt "date2" opts) "use postings/txns' secondary dates instead" |  ,flagNone ["date2","aux-date"] (setboolopt "date2") "use postings/txns' secondary dates instead" | ||||||
| 
 | 
 | ||||||
|  ,flagNone ["cleared","C"]   (\opts -> setboolopt "cleared" opts) "include only cleared postings/txns" |  ,flagNone ["cleared","C"]   (setboolopt "cleared") "include only cleared postings/txns" | ||||||
|  ,flagNone ["uncleared","U"] (\opts -> setboolopt "uncleared" opts) "include only uncleared postings/txns" |  ,flagNone ["uncleared","U"] (setboolopt "uncleared") "include only uncleared postings/txns" | ||||||
|  ,flagNone ["real","R"]      (\opts -> setboolopt "real" opts) "include only non-virtual postings" |  ,flagNone ["real","R"]      (setboolopt "real") "include only non-virtual postings" | ||||||
|  ,flagReq  ["depth"]         (\s opts -> Right $ setopt "depth" s opts) "N" "hide accounts/postings deeper than N" |  ,flagReq  ["depth"]         (\s opts -> Right $ setopt "depth" s opts) "N" "hide accounts/postings deeper than N" | ||||||
|  ,flagNone ["empty","E"]     (\opts -> setboolopt "empty" opts) "show empty/zero things which are normally omitted" |  ,flagNone ["empty","E"]     (setboolopt "empty") "show empty/zero things which are normally omitted" | ||||||
|  ,flagNone ["cost","B"]      (\opts -> setboolopt "cost" opts) "show amounts in their cost price's commodity" |  ,flagNone ["cost","B"]      (setboolopt "cost") "show amounts in their cost price's commodity" | ||||||
|  ] |  ] | ||||||
| 
 | 
 | ||||||
| argsFlag :: FlagHelp -> Arg RawOpts | argsFlag :: FlagHelp -> Arg RawOpts | ||||||
| @ -252,7 +252,7 @@ defcliopts = CliOpts | |||||||
| 
 | 
 | ||||||
| -- | Convert possibly encoded option values to regular unicode strings. | -- | Convert possibly encoded option values to regular unicode strings. | ||||||
| decodeRawOpts :: RawOpts -> RawOpts | decodeRawOpts :: RawOpts -> RawOpts | ||||||
| decodeRawOpts = map (\(name,val) -> (name, fromSystemString val)) | decodeRawOpts = map (\(name',val) -> (name', fromSystemString val)) | ||||||
| 
 | 
 | ||||||
| -- | Parse raw option string values to the desired final data types. | -- | Parse raw option string values to the desired final data types. | ||||||
| -- Any relative smart dates will be converted to fixed dates based on | -- Any relative smart dates will be converted to fixed dates based on | ||||||
| @ -288,26 +288,26 @@ checkCliOpts opts@CliOpts{reportopts_=ropts} = do | |||||||
| -- cmdargs mode, and either return them or, if a help flag is present, | -- cmdargs mode, and either return them or, if a help flag is present, | ||||||
| -- print the mode help and exit the program. | -- print the mode help and exit the program. | ||||||
| getCliOpts :: Mode RawOpts -> IO CliOpts | getCliOpts :: Mode RawOpts -> IO CliOpts | ||||||
| getCliOpts mode = do | getCliOpts mode' = do | ||||||
|   args <- getArgs |   args' <- getArgs | ||||||
|   let rawopts = decodeRawOpts $ processValue mode args |   let rawopts = decodeRawOpts $ processValue mode' args' | ||||||
|   opts <- rawOptsToCliOpts rawopts >>= checkCliOpts |   opts <- rawOptsToCliOpts rawopts >>= checkCliOpts | ||||||
|   debugArgs args opts |   debugArgs args' opts | ||||||
|   -- if any (`elem` args) ["--help","-h","-?"] |   -- if any (`elem` args) ["--help","-h","-?"] | ||||||
|   when ("help" `inRawOpts` rawopts_ opts) $ |   when ("help" `inRawOpts` rawopts_ opts) $ | ||||||
|     putStr (showModeHelp mode) >> exitSuccess |     putStr (showModeHelp mode') >> exitSuccess | ||||||
|   return opts |   return opts | ||||||
|   where |   where | ||||||
|     -- | Print debug info about arguments and options if --debug is present. |     -- | Print debug info about arguments and options if --debug is present. | ||||||
|     debugArgs :: [String] -> CliOpts -> IO () |     debugArgs :: [String] -> CliOpts -> IO () | ||||||
|     debugArgs args opts = |     debugArgs args' opts = | ||||||
|       when ("--debug" `elem` args) $ do |       when ("--debug" `elem` args') $ do | ||||||
|         progname <- getProgName |         progname' <- getProgName | ||||||
|         putStrLn $ "running: " ++ progname |         putStrLn $ "running: " ++ progname' | ||||||
|         putStrLn $ "raw args: " ++ show args |         putStrLn $ "raw args: " ++ show args' | ||||||
|         putStrLn $ "processed opts:\n" ++ show opts |         putStrLn $ "processed opts:\n" ++ show opts | ||||||
|         d <- getCurrentDay |         d <- getCurrentDay | ||||||
|         putStrLn $ "search query: " ++ (show $ queryFromOpts d $ reportopts_ opts) |         putStrLn $ "search query: " ++ show (queryFromOpts d $ reportopts_ opts) | ||||||
| 
 | 
 | ||||||
| -- CliOpts accessors | -- CliOpts accessors | ||||||
| 
 | 
 | ||||||
| @ -422,8 +422,7 @@ hledgerAddons = do | |||||||
|                      -- groupBy (\a b -> dropExtension a == dropExtension b) $ |                      -- groupBy (\a b -> dropExtension a == dropExtension b) $ | ||||||
|                      map stripprefix exes |                      map stripprefix exes | ||||||
|   let displaynames = concatMap stripext $ |   let displaynames = concatMap stripext $ | ||||||
|                      groupBy (\a b -> dropExtension a == dropExtension b) $ |                      groupBy (\a b -> dropExtension a == dropExtension b) precisenames | ||||||
|                      precisenames |  | ||||||
|   return (precisenames, displaynames) |   return (precisenames, displaynames) | ||||||
|   where |   where | ||||||
|     stripprefix = drop (length progname + 1) |     stripprefix = drop (length progname + 1) | ||||||
| @ -456,9 +455,9 @@ isHledgerExeName :: String -> Bool | |||||||
| isHledgerExeName = isRight . parsewith hledgerexenamep | isHledgerExeName = isRight . parsewith hledgerexenamep | ||||||
|     where |     where | ||||||
|       hledgerexenamep = do |       hledgerexenamep = do | ||||||
|         string progname |         _ <- string progname | ||||||
|         char '-' |         _ <- char '-' | ||||||
|         many1 (noneOf ".") |         _ <- many1 (noneOf ".") | ||||||
|         optional (string "." >> choice' (map string addonExtensions)) |         optional (string "." >> choice' (map string addonExtensions)) | ||||||
|         eof |         eof | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user