Library
Module
Module type
Parameter
Class
Class type
Declarative Command-line Parsing for OCaml.
Cmdlang is a library for creating command-line parsers in OCaml. Implemented as an OCaml EDSL, its declarative specification language lives at the intersection of other well-established similar libraries.
Cmdlang exposes a single module named Command
, which contains the entire API to declare command line parsers.
Assuming Cmdlang.Command
to be available in your scope as Command
, the following is a minimalist command that does nothing:
let cmd : unit Command.t =
Command.make
~summary:"A command that does nothing"
(let open Command.Std in
let+ () = Arg.return () in
())
;;
To get started with this API refers to this tutorial from cmdlang's documentation.
module Nonempty_list : sig ... end
A type to represent lists that are statically known to be non-empty.
These interfaces are convenient to use with the Param
module, so you can apply its helpers to custom modules. For example, if your module My_enum
implements the Enumerated_stringable
interface, then you can build a parser for it with:
Param.enumerated (module My_enum)
module type Enumerated_stringable = sig ... end
An interface for types that have a finite number of inhabitants that all have a canonical string representation.
module type Stringable = sig ... end
An interface for types that can be parsed from strings, when parsing never results in failures.
module type Validated_string = sig ... end
An interface for types that can be parsed from strings, with the possibility of parsing failures.
module Param : sig ... end
module Arg : sig ... end
module type Applicative_infix = sig ... end
For use with the ( let+ )
style.
module type Applicative_syntax = sig ... end
For use with the ( let+ )
style:
let cmd : unit Command.t =
Command.make
~summary:"A command that does nothing"
(let open Command.Std in
let+ () = Arg.return () in
())
;;
module Std : sig ... end
For use with the ( let%map_open.Command )
style:
let cmd : unit Command.t =
Command.make
~summary:"A command that does nothing"
(let%map_open.Command () = Arg.return () in
())
;;
module Let_syntax : sig ... end
This module is exported to be used by libraries with strong ties to cmdlang
. Its signature may change in breaking ways at any time without prior notice, and outside of the guidelines set by semver.
module Private : sig ... end