diff --git a/app/MimaRun.hs b/app/MimaRun.hs new file mode 100644 index 0000000..b52e50c --- /dev/null +++ b/app/MimaRun.hs @@ -0,0 +1,41 @@ +module MimaRun where + +import Options.Applicative + +data Settings = Settings + { file :: String + , steps :: Maybe Integer + , memoryDump :: Maybe FilePath + , quiet :: Bool + , sparseOutput :: Bool + } deriving (Show) + +settings :: Parser Settings +settings = Settings + <$> strArgument + (metavar "INFILE" + <> help "The memory dump to load and execute") + <*> (optional . option auto) + (long "steps" + <> short 'n' + <> metavar "N" + <> help "How many instructions to execute (if not specified, runs until HALT or execution exception)") + <*> (optional . strOption) + (long "dump" + <> short 'd' + <> metavar "OUTFILE" + <> help "If specified, the MiMa's memory is dumped to this file after execution is finished") + <*> flag False True + (long "quiet" + <> short 'q' + <> help "Whether to print the memory after execution is finished") + <*> flag False True + (long "sparse" + <> short 's' + <> help "Whether to print memory locations that contain 0") + +opts :: ParserInfo Settings +opts = info (helper <*> settings) $ fullDesc <> failureCode 1 + +main :: IO () +main = execParser opts >>= print diff --git a/package.yaml b/package.yaml index c473e8a..3a0fbc2 100644 --- a/package.yaml +++ b/package.yaml @@ -19,15 +19,27 @@ extra-source-files: description: Please see the README on GitHub at dependencies: -- base >= 4.7 && < 5 -- bytestring >= 0.10.8 && < 0.11 -- containers >= 0.6.0 && < 0.7 -- text >= 1.2.3 && < 1.3 +- base >= 4.7 && < 5 +- bytestring >= 0.10.8 && < 0.11 +- containers >= 0.6.0 && < 0.7 +- text >= 1.2.3 && < 1.3 +- optparse-applicative >= 0.14.3 && < 0.15 library: source-dirs: src executables: + mima-run: + main: MimaRun.hs + source-dirs: app + ghc-options: + - -main-is MimaRun + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - mima-tools + mima-tools-exe: main: Main.hs source-dirs: app