- fileName <- head <$> getArgs
- blocks <- parseScript <$> readFile fileName
- print blocks
- rootDir <- getCurrentDirectory
- runBlocks rootDir blocks
-
-runBlocks :: FilePath -> [Block] -> IO ()
-runBlocks rootDir blocks = runMachine rootDir (map convertBlock blocks) >>= putStrLn
+ args <- getArgs
+ curDir <- getCurrentDirectory
+ case args of
+ ["replay", cmd] -> replaySession cmd curDir
+ [file, cmd] -> do
+ blocks <- parseScript <$> readFile file
+ success <- runBlocks cmd curDir blocks
+ if success
+ then putStrLn "Success ✅"
+ else putStrLn "Failed ❌" >> exitFailure
+ _ -> putStrLn "usage: lsp-test (replay <cmd>)|(<file> <cmd>)"
+
+runBlocks :: String -> FilePath -> [Block] -> IO Bool
+runBlocks cmd rootDir blocks = runMachine cmd rootDir (map convertBlock blocks)