[project @ 2004-11-18 16:39:53 by stolz]
[ghc-hetmet.git] / glafp-utils / nofib-analyse / CmdLine.hs
1 -----------------------------------------------------------------------------
2 -- CmdLine.hs
3
4 -- (c) Simon Marlow 1999
5 -----------------------------------------------------------------------------
6
7 module CmdLine where
8
9 import GetOpt
10 import System
11 import IOExts
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   | OptHelp
42   deriving Eq
43
44 argInfo :: [ OptDescr CLIFlags ]
45 argInfo = 
46   [ Option ['?'] ["help"]    (NoArg OptHelp)        
47         "Display this message"
48   , Option ['a'] ["ascii"]   (NoArg OptASCIIOutput) 
49         "Produce ASCII output (default)"
50   , Option ['h'] ["html"]    (NoArg OptHTMLOutput)  
51         "Produce HTML output"
52   , Option ['i'] ["ignore"]  (ReqArg (OptIgnoreSmallTimes . read) "secs")
53         "Ignore runtimes smaller than <secs>"
54   , Option ['d'] ["deviations"] (NoArg OptDeviations)
55         "Display deviations (default)"
56   , Option ['l'] ["latex"]    (NoArg OptLaTeXOutput)  
57         "Produce LaTeX output"
58   , Option ['n'] ["nodeviations"] (NoArg OptNoDeviations)
59         "Hide deviations"
60   , Option ['t'] ["title"] (ReqArg OptTitle "title")
61         "Specify report title"
62   ]
63