diff options
Diffstat (limited to 'bin/main.ml')
-rw-r--r-- | bin/main.ml | 26 |
1 files changed, 26 insertions, 0 deletions
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 @@ | |||
1 | open Core | ||
2 | |||
3 | let repl = | ||
4 | Command.basic ~summary:"run the Mininix REPL" (Command.Param.return Repl.run) | ||
5 | |||
6 | let eval = | ||
7 | Command.basic ~summary:"run a Nix file" | ||
8 | (let%map_open.Command filename = anon ("FILENAME" %: string) | ||
9 | and strict = flag "strict" no_arg ~doc:"use deep evaluation strategy" | ||
10 | and importsdef = | ||
11 | flag "importsdef" (optional string) ~doc:"import tree definition file" | ||
12 | in | ||
13 | fun () -> | ||
14 | Settings.opts.eval_strategy := if strict then `Deep else `Shallow; | ||
15 | Settings.opts.imports_def_file := importsdef; | ||
16 | let ok = | ||
17 | if String.(filename = "-") then Run.eval_stdin () | ||
18 | else Run.eval_file filename | ||
19 | in | ||
20 | if ok then exit 0 else exit 1) | ||
21 | |||
22 | let main = | ||
23 | Command.group ~summary:"the Mininix interpreter" | ||
24 | [ ("repl", repl); ("eval", eval) ] | ||
25 | |||
26 | let () = Command_unix.run main | ||