1 module Parse ( ekitaiOpts, optTimeStep ) where
3 import System.Console.GetOpt
4 import System.Environment
15 defaultOptions = Options
21 options :: [OptDescr (Options -> Options)]
23 [ Option ['h'] ["help"]
24 (NoArg (\opts -> opts { optHelp = True }))
25 "display's this message"
26 , Option ['c'] ["color", "colour"]
27 (NoArg (\opts -> opts { optColor = True }))
29 , Option ['t'] ["timestep"]
30 (ReqArg (\t opts -> opts { optTimeStep = read t :: Int }) "timestep")
31 "sets the simulation time step"
34 ekitaiOpts :: [String] -> IO (Options, String)
36 case getOpt RequireOrder options argv of
37 (o, [n], []) -> return (foldl (flip id) defaultOptions o, n)
38 (o, _, []) -> ioError $ userError $ "missing input file"
39 (_, _, errs) -> ioError $ userError $ concat errs
41 -- ++ usageInfo header options
42 -- where header = "Usage: ekitai [OPTIONS...] simfile"
45 -- opts <- (foldl (flip id) defaultOptions o)
46 -- if optHelp then userError $ concat usageInfo "Usage: ekitai [OPTIONS...] simfile" options
47 -- else ioError $ userError $ "missing input file"