From ba61dfd69504ec6263a9dee9931d93adeb6f3142 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Mon, 7 Jul 2025 21:52:08 +0200 Subject: Initialize repository --- bin/main.ml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bin/main.ml (limited to 'bin/main.ml') diff --git a/bin/main.ml b/bin/main.ml new file mode 100644 index 0000000..e4ca4b9 --- /dev/null +++ b/bin/main.ml @@ -0,0 +1,26 @@ +open Core + +let repl = + Command.basic ~summary:"run the Mininix REPL" (Command.Param.return Repl.run) + +let eval = + Command.basic ~summary:"run a Nix file" + (let%map_open.Command filename = anon ("FILENAME" %: string) + and strict = flag "strict" no_arg ~doc:"use deep evaluation strategy" + and importsdef = + flag "importsdef" (optional string) ~doc:"import tree definition file" + in + fun () -> + Settings.opts.eval_strategy := if strict then `Deep else `Shallow; + Settings.opts.imports_def_file := importsdef; + let ok = + if String.(filename = "-") then Run.eval_stdin () + else Run.eval_file filename + in + if ok then exit 0 else exit 1) + +let main = + Command.group ~summary:"the Mininix interpreter" + [ ("repl", repl); ("eval", eval) ] + +let () = Command_unix.run main -- cgit v1.2.3