Implement basic mima-run functionality
Bugs fixed: - Print correct file name when load/save error occurs - Correctly identify invalid file formats
This commit is contained in:
parent
362025c8df
commit
6b81fd67b4
5 changed files with 52 additions and 16 deletions
|
|
@ -1,10 +1,31 @@
|
|||
module Main where
|
||||
|
||||
import Options.Applicative
|
||||
import Control.Monad.IO.Class
|
||||
import qualified Data.Text.IO as T
|
||||
import Options.Applicative
|
||||
|
||||
import Mima.MimaRun.Options
|
||||
import Mima.Format
|
||||
import Mima.MimaRun.Options
|
||||
import Mima.Run
|
||||
import Mima.Vm.State
|
||||
import Mima.Vm.Storage
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
opts <- execParser parserInfo
|
||||
putStrLn $ "The options are: " ++ show opts
|
||||
main = runOrExit 2 $ do
|
||||
opts <- liftIO $ execParser parserInfo
|
||||
initialState <- loadMimaState $ inputFile opts
|
||||
finalState <- liftIO $ case steps opts of
|
||||
Nothing -> do
|
||||
let (finalState, abortReason, stepsMade) = execute initialState
|
||||
putStrLn $ "Stopped after " ++ show stepsMade ++ " steps, reason:"
|
||||
T.putStrLn $ toText abortReason
|
||||
pure finalState
|
||||
Just n -> do
|
||||
let (finalState, mAbortReason, stepsMade) = executeN n initialState
|
||||
putStrLn $ "Stopped after " ++ show stepsMade ++ " steps, reason:"
|
||||
case mAbortReason of
|
||||
Nothing -> putStrLn "Ran out of steps"
|
||||
Just abortReason -> T.putStrLn $ toText abortReason
|
||||
pure finalState
|
||||
liftIO $ putStrLn ""
|
||||
liftIO $ print finalState
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue