diff --git a/mima-run/Main.hs b/mima-run/Main.hs index cf9a9cc..b98fa8b 100644 --- a/mima-run/Main.hs +++ b/mima-run/Main.hs @@ -1,4 +1,10 @@ module Main where +import Options.Applicative + +import Mima.MimaRun.Options + main :: IO () -main = putStrLn "In the beginning, there was nothing." +main = do + opts <- execParser parserInfo + putStrLn $ "The options are: " ++ show opts diff --git a/mima-run/Mima/MimaRun/Options.hs b/mima-run/Mima/MimaRun/Options.hs new file mode 100644 index 0000000..70d1ba4 --- /dev/null +++ b/mima-run/Mima/MimaRun/Options.hs @@ -0,0 +1,27 @@ +module Mima.MimaRun.Options + ( Options(..) + , parserInfo + ) where + +import Options.Applicative + +data Options = Options + { inputFile :: FilePath + , steps :: Maybe Integer + } deriving (Show) + +parser :: Parser Options +parser = Options + <$> strOption + ( help "The .mima file to use" + <> metavar "INPUTFILE" + ) + <*> (optional . option auto) + ( short 'n' + <> long "steps" + <> help "Maximum number of steps to execute" + <> metavar "STEPS" + ) + +parserInfo :: ParserInfo Options +parserInfo = info (parser <**> helper) (failureCode 1) diff --git a/package.yaml b/package.yaml index 2f8c9db..37cd574 100644 --- a/package.yaml +++ b/package.yaml @@ -19,6 +19,7 @@ dependencies: - binary - bytestring - containers + - optparse-applicative - text - transformers - unordered-containers