ocamlocaml-core

Core.Command.run : API changed between v0.14 and v0.15?


The following code that was compiling successfully with Core v0.14 (ocaml 4.10), but fails with v0.15 (ocaml 4.11).

open Core;;
let command = Command.basic ~summary:"essai" (
  let open Command.Let_syntax in
  let%map_open s = anon(sequence ("n" %: int))  in 
  fun () ->
    List.iter s ~f:(fun x -> Printf.printf "n = %d\n" x ) ;
  )

 
let () = Command.run ~version:"0.0" ~build_info:"RWO" command;;

The error (with 4.11) :

File "cli.ml", line 10, characters 9-20:
10 | let () = Command.run ~version:"0.0" ~build_info:"RWO" command;;
              ^^^^^^^^^^^
Error (alert deprecated): Core.Command.run
[since 2021-03] Use [Command_unix]
File "cli.ml", line 10, characters 9-20:
10 | let () = Command.run ~version:"0.0" ~build_info:"RWO" command;;
              ^^^^^^^^^^^
Error: This expression has type [ `Use_Command_unix ]
       This is not a function; it cannot be applied.

The documentation of Core.Command.run states that it is obsolete - but I fail to find how to replace it.


Solution

  • I think you're looking for Command_unix as indicated by the message you received. Documentation link for Command_unix.run.