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 thatCommand
needs, in particular to implement theshape
andrun
functions.Core_kernel.Private.Command
is a functor taking a module matchingFor_unix
and is applied in Core to constructCore.Command
. We use a functor in this way so thatCommand
's internal data types can remain hidden.
module type Command = sig ... end