diff --git a/app/Main.hs b/app/Main.hs index ce0017e8..6f7d599d 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -81,6 +81,11 @@ main = do args <- SystemEnvironment.getArgs runInputT settings (repl finalContext "") Build -> do _ <- executeString True finalContext ":b" "Compiler (Build)" return () + Install thing -> + do _ <- executeString True finalContext + ("(install \"" ++ thing ++ "\")") + "Installation" + return () BuildAndRun -> do _ <- executeString True finalContext ":bx" "Compiler (Build & Run)" -- TODO: Handle the return value from executeString and return that one to the shell return () @@ -103,6 +108,7 @@ parseArgs args = parseArgsInternal [] Repl [] args case arg of "-b" -> parseArgsInternal filesToLoad Build otherOptions restArgs "-x" -> parseArgsInternal filesToLoad BuildAndRun otherOptions restArgs + "-i" -> parseArgsInternal filesToLoad (Install (head restArgs)) otherOptions (tail restArgs) "--check" -> parseArgsInternal filesToLoad Check otherOptions restArgs "--no-core" -> parseArgsInternal filesToLoad execMode (NoCore : otherOptions) restArgs "--log-memory" -> parseArgsInternal filesToLoad execMode (LogMemory : otherOptions) restArgs diff --git a/core/Core.carp b/core/Core.carp index 72159875..233dfdff 100644 --- a/core/Core.carp +++ b/core/Core.carp @@ -20,3 +20,4 @@ (load "Map.carp") (load "Heap.carp") (load "Sort.carp") +(load "Install.carp") diff --git a/core/Install.carp b/core/Install.carp new file mode 100644 index 00000000..7682640b --- /dev/null +++ b/core/Install.carp @@ -0,0 +1,8 @@ +(defn install [file] + (let [split (String.split-by file &[\@])] + (if (= (Array.length &split) 1) + (System.system &(fmt "git clone %s" file)) + (do + (System.system &(fmt "git clone %s" file)) + (comment TODO: check out tag) + )))) diff --git a/src/Eval.hs b/src/Eval.hs index de994cfd..8200dca5 100644 --- a/src/Eval.hs +++ b/src/Eval.hs @@ -447,6 +447,7 @@ catcher ctx exception = case contextExecMode ctx of Repl -> return ctx Build -> exitWith (ExitFailure returnCode) + Install _ -> exitWith (ExitFailure returnCode) BuildAndRun -> exitWith (ExitFailure returnCode) Check -> exitWith ExitSuccess diff --git a/src/Obj.hs b/src/Obj.hs index 2fb822b2..32e03d6d 100644 --- a/src/Obj.hs +++ b/src/Obj.hs @@ -618,7 +618,7 @@ forceTy :: XObj -> Ty forceTy xobj = fromMaybe (error ("No type in " ++ show xobj)) (ty xobj) -- | How should the compiler be run? Interactively or just build / build & run and then quit? -data ExecutionMode = Repl | Build | BuildAndRun | Check deriving (Show, Eq) +data ExecutionMode = Repl | Build | BuildAndRun | Install String | Check deriving (Show, Eq) -- | Information needed by the REPL data Context = Context { contextGlobalEnv :: Env