aboutsummaryrefslogtreecommitdiffstats
path: root/bin/main.ml
blob: e4ca4b95cbc057b8dec22519f0aa1f6fdae0333b (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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