package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Command-line flag specifications.

type 'a t
val required : 'a Arg_type.t -> 'a t

Required flags must be passed exactly once.

val optional : 'a Arg_type.t -> 'a Base.Option.t t

Optional flags may be passed at most once.

val optional_with_default : 'a -> 'a Arg_type.t -> 'a t

optional_with_default flags may be passed at most once, and default to a given value.

val listed : 'a Arg_type.t -> 'a Base.List.t t

listed flags may be passed zero or more times.

val one_or_more : 'a Arg_type.t -> ('a * 'a Base.List.t) t
  • deprecated [since 2021-07] Use [one_or_more_as_pair] or [one_or_more_as_list]
val one_or_more_as_pair : 'a Arg_type.t -> ('a * 'a Base.List.t) t

one_or_more_as_pair flags must be passed one or more times.

val one_or_more_as_list : 'a Arg_type.t -> 'a Base.List.t t

Like one_or_more_as_pair, but returns the flag values as a list.

val no_arg : Base.Bool.t t

no_arg flags may be passed at most once. The boolean returned is true iff the flag is passed on the command line.

val no_arg_register : key:'a Univ_map.With_default.Key.t -> value:'a -> Base.Bool.t t

no_arg_register ~key ~value is like no_arg, but associates value with key in the autocomplete environment.

val no_arg_some : 'a -> 'a Base.Option.t t

no_arg_some value is like no_arg, but will return Some value if the flag is passed on the command line, and return None otherwise.

val no_arg_abort : exit:(Base.Unit.t -> Nothing.t) -> Base.Unit.t t

no_arg_abort ~exit is like no_arg, but aborts command-line parsing by calling exit. This flag type is useful for "help"-style flags that just print something and exit.

val escape : Base.String.t Base.List.t Base.Option.t t

escape flags may be passed at most once. They cause the command line parser to abort and pass through all remaining command line arguments as the value of the flag.

A standard choice of flag name to use with escape is "--".

val map_flag : 'a t -> f:('a -> 'b) -> 'b t

map_flag flag ~f transforms the parsed result of flag by applying f.

OCaml

Innovation. Community. Security.