package clim

  1. Overview
  2. Docs

Module ClimSource

Command Line Interface Maker

Sourcetype 'a conv = 'a Cmdliner.Arg.conv

Converter type from Cmdliner.

Sourcetype spec

Type flag meaning the argument isn't fully specified.

Sourcetype final

Type flag meaning the argument is fully specified.

Sourcetype ('a, 'b) arg

The argument type.

Flags

Flags are boolean values which don't need value: only their presence (true) or not (false) give their value.

Sourceval flag : ?docs:string -> ?doc:string -> ?env:string -> string list -> (bool, spec) arg

flag ~docs ~doc ~env aka defines a new flag whose names are given in aka.

Optional Arguments

Optional arguments are the usual argument specified by a -x or --xxx notation on command line.

Sourceval opt : ?docs:string -> ?docv:string -> ?doc:string -> ?env:string -> ?vopt:'a -> 'a conv -> 'a -> string list -> ('a, spec) arg

opt ~docs ~docv ~doc ~env ~vopt conv default aka defines a new optional argument whose names are given in aka.

Sourceval opt_all : ?docs:string -> ?docv:string -> ?doc:string -> ?env:string -> ?vopt:'a -> 'a conv -> 'a list -> string list -> ('a list, spec) arg

opt_all ~docs ~docv ~doc ~env ~vopt conv default aka same as opt but gathers several invocations of the options into a list. For example, this is useful for include directory options used in many tools.

Positional Arguments

Positional arguments have no name and are supposely mandatory and ordered on command line.

For now, positional arguments combinators are somehow illformed and will be modified in near future so use it carefuly.

Sourceval pos : ?docs:string -> ?docv:string -> ?doc:string -> ?env:string -> ?rev:bool -> 'a conv -> 'a -> int -> ('a, spec) arg
Sourceval pos_all : ?docs:string -> ?docv:string -> ?doc:string -> ?env:string -> 'a conv -> 'a list -> ('a list, spec) arg

Contraints

To finalize an argument, the following constraints can be used.

Sourceval value : ('a, spec) arg -> ('a, final) arg

value a finalizes the argument a as itself.

Sourceval required : ('a option, spec) arg -> ('a, final) arg

required a ensures that argument a holding a optional value is given on command line.

Sourceval non_empty : ('a list, spec) arg -> ('a list, final) arg

non_empty a ensures that argument a holding a list is not empty.

Sourceval last : ('a list, spec) arg -> ('a, final) arg

last a ensures that only the last given value on command line will be used for a.

Configurations

Configurations hold the command line argument to be used.

Sourcetype cfg

Configuration type.

Sourceval create : unit -> cfg

Creates an empty configuration.

Sourceval from : cfg -> cfg

from cfg creates a new configuration based on cfg.

Sourceval register : cfg -> ('a, final) arg -> unit -> 'a

register cfg arg registers the argument arg info cfg and returns a getter to the option's value.

Commands

Since commands can have multiple related environment variable, we inherit their definitions from Cmdliner.

Environment variable specification type.

Sourceval env : ?docs:string -> ?doc:string -> string -> env

env ~docs ~doc name creates a ne environment variable specification named name.

Sourcetype 'a command = {
  1. cfg : cfg;
    (*

    The related configuration.

    *)
  2. cmd : unit -> 'a;
    (*

    The command entrypoint.

    *)
  3. man_xrefs : Cmdliner.Manpage.xref list;
    (*

    Man references.

    *)
  4. man : Cmdliner.Manpage.block list;
    (*

    Additional man documentation.

    *)
  5. envs : env list;
    (*

    Environment variables.

    *)
  6. doc : string;
    (*

    Main documentation.

    *)
  7. version : string option;
    (*

    Version (if any).

    *)
  8. name : string;
    (*

    Binary name.

    *)
}

The command type. It gathers all Cmdliner related informations into one simle data structure.

Sourceval command : ?cfg:cfg -> ?man_xrefs:Cmdliner.Manpage.xref list -> ?man:Cmdliner.Manpage.block list -> ?envs:env list -> ?doc:string -> ?version:string option -> ?name:string -> (unit -> 'b) -> 'b command

Command maker.

term cmd returns the Cmdliner terms and info needed to use Cmdliner. This ensures some compatiblity with Cmdliner if defining a legacy Cmdliner command term.

Sourceval run : 'a command -> 'a

run cmd parses the command line according to the cmd specification and returns the result of the underlying function.

Sourceval bool : bool conv

Converters

The following converters are inherited from Cmdliner.

Sourceval char : char conv
Sourceval int : int conv
Sourceval nativeint : nativeint conv
Sourceval int32 : int32 conv
Sourceval int64 : int64 conv
Sourceval float : float conv
Sourceval string : string conv
Sourceval enum : (string * 'a) list -> 'a conv
Sourceval file : string conv
Sourceval dir : string conv
Sourceval non_dir_file : string conv
Sourceval option : ?none:string -> 'a conv -> 'a option conv
Sourceval list : ?sep:char -> 'a conv -> 'a list conv
Sourceval array : ?sep:char -> 'a conv -> 'a array conv
Sourceval pair : ?sep:char -> 'a conv -> 'b conv -> ('a * 'b) conv
Sourceval t2 : ?sep:char -> 'a conv -> 'b conv -> ('a * 'b) conv
Sourceval t3 : ?sep:char -> 'a conv -> 'b conv -> 'c conv -> ('a * 'b * 'c) conv
Sourceval t4 : ?sep:char -> 'a conv -> 'b conv -> 'c conv -> 'd conv -> ('a * 'b * 'c * 'd) conv
Sourceclass virtual 'r cli : object ... end

The Object-Oriented CLI definition

OCaml

Innovation. Community. Security.