[project @ 2000-02-18 10:26:19 by simonmar]
[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 data CLIFlags
26   = OptASCIIOutput
27   | OptHTMLOutput
28   | OptIgnoreSmallTimes Float
29   | OptHelp
30   deriving Eq
31
32 argInfo :: [ OptDescr CLIFlags ]
33 argInfo = 
34   [ Option ['?'] ["help"]    (NoArg OptHelp)        
35         "Display this message"
36   , Option ['a'] ["ascii"]   (NoArg OptASCIIOutput) 
37         "Produce ASCII output (default)"
38   , Option ['h'] ["html"]    (NoArg OptHTMLOutput)  
39         "Produce HTML output"
40   , Option ['i'] ["ignore"]  (ReqArg (OptIgnoreSmallTimes . read) "secs")
41         "Ignore runtimes smaller than <secs>"
42   ]
43