Module Core_kernel__Command_intf

Purely functional command line parsing.

Here is a simple example:

let () =
  let open Command.Let_syntax in
  Command.basic
    ~summary:"cook eggs"
    [%map_open
      let num_eggs =
        flag "num-eggs" (required int) ~doc:"COUNT cook this many eggs"
      and style =
        flag "style" (required (Arg_type.create Egg_style.of_string))
          ~doc:"OVER-EASY|SUNNY-SIDE-UP style of eggs"
      and recipient =
        anon ("recipient" %: string)
      in
      fun () ->
        (* TODO: implement egg-cooking in ocaml *)
        failwith "no eggs today"
    ]
  |> Command.run

Note: Command.Param has replaced Command.Spec (DEPRECATED) and should be used in all new code.

module type For_unix = sig ... end

For_unix is the subset of Core's interface that Command needs, in particular to implement the shape and run functions. Core_kernel.Private.Command is a functor taking a module matching For_unix and is applied in Core to construct Core.Command. We use a functor in this way so that Command's internal data types can remain hidden.

module type Command = sig ... end