- (* Get stdlib directory. *)
- let datadir =
- try Sys.getenv "GOALS_DATADIR" with Not_found -> Config.datadir in
- let stdlibdir = datadir // "stdlib" in
- let prelude_gl = stdlibdir // "prelude.gl" in
- if not (is_directory stdlibdir) || not (Sys.file_exists prelude_gl) then
- failwithf "%s: cannot find the standard library directory, expected %s. If the standard library directory is in a non-standard location then set GOALS_DATADIR. If you can trying to run goals from the build directory then use ‘./run goals ...’"
- Sys.executable_name stdlibdir;
-
- (* Command line arguments. *)
- let args = ref [] in
- let directory = ref "." in
- let filename = ref "Goalfile" in
-
- let argspec = [
- "-C", Arg.Set_string directory,
- "directory Change to directory before running";
- "--directory", Arg.Set_string directory,
- "directory Change to directory before running";
- "-f", Arg.Set_string filename,
- "filename Set name of Goalfile";
- "--file", Arg.Set_string filename,
- "filename Set name of Goalfile";
- "-V", Arg.Unit print_version,
- " Print version and exit";
- "--version", Arg.Unit print_version,
- " Print version and exit";
- ] in
- let argspec = Arg.align argspec in
- let anon_fun s = args := s :: !args in
- Arg.parse argspec anon_fun usage;