package functoria

  1. Overview
  2. Docs

Cross-stage command-line arguments.

Terms for cross-stage arguments.

This module extends Cmdliner.Arg to allow MetaOCaml-style typed cross-stage persistency of command-line arguments.

Argument converters

type 'a serialize = Stdlib.Format.formatter -> 'a -> unit

The type for command-line argument serializers. A value of type 'a serialize generates a syntactically valid OCaml representation which evaluates to a value of type 'a.

type 'a runtime_conv = string

The type for command-line argument converters used at runtime. A value of type 'a runtime_conv is a symbol name of type Cmdliner.Arg.converter.

type 'a converter

The type for argument converters.

val conv : conv:'a Cmdliner.Arg.conv -> serialize:'a serialize -> runtime_conv:'a runtime_conv -> 'a converter

conv c s r is the argument converter using c to convert user strings into OCaml value, s to convert OCaml values into strings interpretable as OCaml expressions, and the function named r to convert user strings into OCaml values at runtime.

val string : string converter

string converts strings.

val bool : bool converter

bool converts booleans.

val int : int converter

int converts integers.

val int64 : int64 converter

int64 converts 64-bits integers.

val list : 'a converter -> 'a list converter

list t converts lists of ts.

val some : 'a converter -> 'a option converter

some t converts t options.

Arguments and their information

type 'a t

The type for arguments holding data of type 'a.

type info

The type for information about cross-stage command-line arguments. See Cmdliner's arguments.

val info : ?docs:string -> ?docv:string -> ?doc:string -> ?env:string -> string list -> info

Define cross-stage information for an argument. See Cmdliner.Arg.info. If not set, docs is "UNIKERNEL PARAMETERS".

Optional Arguments

type stage = [
  1. | `Configure
  2. | `Run
  3. | `Both
]

The type for specifying at which stage an argument is available.

  • `Configure means that the argument is read on the command-line at configuration-time.
  • `Run means that the argument is read on the command-line at runtime.
  • `Both means that the argument is read on the command-line both at configuration-time and run-time.
val opt : ?stage:stage -> 'a converter -> 'a -> info -> 'a t

opt conv v i is similar to Cmdliner.Arg.opt but for cross-stage optional command-line arguments. If not set, stage is `Both.

val required : ?stage:stage -> 'a converter -> info -> 'a option t

required conv i is similar to Cmdliner.Arg.required but for cross-stage required command-line arguments. If not set, stage is `Both.

val flag : ?stage:stage -> info -> bool t

flag i is similar to Cmdliner.Arg.flag but for cross-stage command-line flags. If not set, stage is `Both.

val opt_all : ?stage:stage -> 'a converter -> info -> 'a list t
OCaml

Innovation. Community. Security.