added file suffix and check

This commit is contained in:
sebastian 2023-03-26 00:09:47 +01:00
parent ac43af8110
commit d49e2401bf
2 changed files with 42 additions and 25 deletions

View file

@ -16,24 +16,39 @@ import Data.List.Extra (isSuffixOf)
import Compiler (compile)
import Renamer.Renamer (rename)
import System.Directory (createDirectory, doesPathExist,
import System.Directory (
createDirectory,
doesPathExist,
getDirectoryContents,
removeDirectoryRecursive,
setCurrentDirectory)
setCurrentDirectory,
)
import System.Environment (getArgs)
import System.Exit (ExitCode, exitFailure,
exitSuccess)
import System.Exit (
ExitCode,
exitFailure,
exitSuccess,
)
import System.IO (stderr)
import System.Process.Extra (readCreateProcess, shell,
spawnCommand, waitForProcess)
import System.Process.Extra (
readCreateProcess,
shell,
spawnCommand,
waitForProcess,
)
import TypeChecker.TypeChecker (typecheck)
main :: IO ()
main =
getArgs >>= \case
[] -> print "Required file path missing"
("-d" : s : _) -> main' True s
(s : _) -> main' False s
[] -> putStrLn "Required file path missing"
["-d", s] -> do
when (".crf" `isSuffixOf` s) (main' True s)
putStrLn $ "File '" ++ s ++ "' is not a churf file"
[s] -> do
when (".crf" `isSuffixOf` s) (main' False s)
putStrLn $ "File '" ++ s ++ "' is not a churf file"
xs -> putStrLn $ "Can't process: " ++ unwords xs
main' :: Bool -> String -> IO ()
main' debug s = do

View file

@ -26,3 +26,5 @@ bind ma f = case ma of {
Nothing => Nothing ;
Just a => f a ;
};