How are command line argument are treated in toplevel?

210 Views Asked by At

I have a program which takes command line argument. The same of source file is encode.ml. I want to load this file in the toplevel.

Is there way to load the source file in the toplevel where we can pass it a command line arguments?

Thanks.

1

There are 1 best solutions below

3
ivg On BEST ANSWER

Yes, invoke your toplevel with ocaml encode.ml arg1 arg2 etc. The following program demonstrates it:

$ cat args.ml
let () =
  Array.iteri (Printf.printf "%d -> %s\n") Sys.argv

$ ocaml args.ml -h --help -help
0 -> args.ml
1 -> -h
2 -> --help
3 -> -help