remove empty dir
[ghc-hetmet.git] / utils / nofib-analyse / CmdLine.hs
1 -----------------------------------------------------------------------------
2 -- CmdLine.hs
3
4 -- (c) Simon Marlow 2005
5 -----------------------------------------------------------------------------
6
7 module CmdLine where
8
9 import System.Console.GetOpt
10 import System.Environment       ( getArgs )
11 import System.IO.Unsafe         ( unsafePerformIO )
12
13 -----------------------------------------------------------------------------
14 -- Command line arguments
15
16 args = unsafePerformIO getArgs
17 (flags, other_args, cmdline_errors) = getOpt Permute argInfo args 
18
19 default_tooquick_threshold = 0.2 {- secs -} :: Float
20 tooquick_threshold
21  = case [ i | OptIgnoreSmallTimes i <- flags ] of
22         [] -> default_tooquick_threshold
23         (i:_) -> i
24
25 devs   = OptDeviations   `elem` flags
26 nodevs = OptNoDeviations `elem` flags
27
28 default_title = "NoFib Results"
29 reportTitle = case [ t | OptTitle t <- flags ] of
30         []    -> default_title
31         (t:_) -> t
32
33 data CLIFlags
34   = OptASCIIOutput
35   | OptLaTeXOutput
36   | OptHTMLOutput
37   | OptIgnoreSmallTimes Float
38   | OptDeviations
39   | OptNoDeviations
40   | OptTitle String
41   | OptColumns String
42   | OptRows String
43   | OptHelp
44   deriving Eq
45
46 argInfo :: [ OptDescr CLIFlags ]
47 argInfo = 
48   [ Option ['?'] ["help"]    (NoArg OptHelp)        
49         "Display this message"
50   , Option ['a'] ["ascii"]   (NoArg OptASCIIOutput) 
51         "Produce ASCII output (default)"
52   , Option ['h'] ["html"]    (NoArg OptHTMLOutput)  
53         "Produce HTML output"
54   , Option ['i'] ["ignore"]  (ReqArg (OptIgnoreSmallTimes . read) "secs")
55         "Ignore runtimes smaller than <secs>"
56   , Option ['d'] ["deviations"] (NoArg OptDeviations)
57         "Display deviations (default)"
58   , Option ['l'] ["latex"]    (NoArg OptLaTeXOutput)  
59         "Produce LaTeX output"
60   , Option [] ["columns"] (ReqArg OptColumns "COLUMNS")
61         "Specify columns for summary table (comma separates)"
62   , Option [] ["rows"] (ReqArg OptRows "ROWS")
63         "Specify rows for summary table (comma separates)"
64   , Option ['n'] ["nodeviations"] (NoArg OptNoDeviations)
65         "Hide deviations"
66   , Option ['t'] ["title"] (ReqArg OptTitle "title")
67         "Specify report title"
68   ]
69