--- /dev/null
+import System.Environment
+
+import Parse
+
+main = do
+ argv <- getArgs
+ (opts, fname) <- ekitaiOpts argv
+ putStrLn fname
+ return 0
+
+module Parse ( ekitaiOpts ) where
+
import System.Console.GetOpt
import System.Environment
-import System.Exit
import Data.Maybe
import Data.Either
-data Flag
-
data Options = Options
{ optHelp :: Bool
, optColor :: Bool
"enables color"
]
-ekitaiOpts :: [String] -> Either String (Options, String)
+ekitaiOpts :: [String] -> IO (Options, String)
ekitaiOpts argv =
case getOpt RequireOrder options argv of
- (o, n, []) -> undefined
- (_, _, err) -> Left "invalid"
-
-main = do
- argv <- getArgs
- return 0
+ (o, [n], []) -> return (foldl (flip id) defaultOptions o, n)
+ (o, _, []) -> ioError $ userError $ "must supply input file"
+ (_, _, errs) -> ioError $ userError $ (concat errs)