package cmdlang

  1. Overview
  2. Docs

Refer to the Arguments terminology.

type 'a t

Applicative operations

val return : 'a -> 'a t
val apply : ('a -> 'b) t -> 'a t -> 'b t
val map : 'a t -> f:('a -> 'b) -> 'b t
val both : 'a t -> 'b t -> ('a * 'b) t

Named arguments

val flag : string Nonempty_list.t -> doc:string -> bool t

A flag that may appear at most once on the command line.

val flag_count : string Nonempty_list.t -> doc:string -> int t

A flag that may appear multiple times on the command line. Evaluates to the number of times the flag appeared.

val named : ?docv:string -> string Nonempty_list.t -> 'a Param.t -> doc:string -> 'a t

A required named argument (must appear exactly once on the command line).

val named_multi : ?docv:string -> string Nonempty_list.t -> 'a Param.t -> doc:string -> 'a list t

A named argument that may appear multiple times on the command line.

val named_opt : ?docv:string -> string Nonempty_list.t -> 'a Param.t -> doc:string -> 'a option t

An optional named argument (may appear at most once).

val named_with_default : ?docv:string -> string Nonempty_list.t -> 'a Param.t -> default:'a -> doc:string -> 'a t

An optional named argument with a default value.

Positional arguments

Positional argument start at index 0.

val pos : ?docv:string -> pos:int -> 'a Param.t -> doc:string -> 'a t

A required positional argument. It must appear exactly once at position i on the command line.

val pos_opt : ?docv:string -> pos:int -> 'a Param.t -> doc:string -> 'a option t

An optional positional argument at position i. Optional positional argument must not be followed by more positional argument as this creates ambiguous specifications.

val pos_with_default : ?docv:string -> pos:int -> 'a Param.t -> default:'a -> doc:string -> 'a t

A optional positional argument with a default value.

val pos_all : ?docv:string -> 'a Param.t -> doc:string -> 'a list t

Return the list of all remaining positional arguments.

OCaml

Innovation. Community. Security.