Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Climate.Arg_parser
SourceA DSL for declaratively describing a program's command-line arguments
A parser of values of type 'a
Make a 'a print
value from a to_string function
type 'a conv = {
parse : 'a parse;
print : 'a print;
default_value_name : string;
completion : 'a Completion.t option;
}
Knows how to interpret strings on the command line as a particular type and how to format values of said type as strings. Define a custom _ conv
value to implement a parser for a custom type.
val make_conv :
parse:'a parse ->
print:'a print ->
?default_value_name:string ->
?completion:'a Completion.t option ->
unit ->
'a conv
Helper function for constructing '_ conv
s
Similar to string
except its default value name and completion is specialized for files.
val enum :
?default_value_name:string ->
?eq:('a -> 'a -> bool) ->
(string * 'a) list ->
'a conv
enum values ~eq
returns a conv for a concrete set of possible values of type 'a
. The values and their names are given by the values
argument and eq
is used when printing values to tie a given value of type 'a
to a name.
string_enum values ~eq
returns a conv for a concrete set of possible strings.
pair ~sep a b
returns a conv for a pair of values separated by the first occurance of sep
(',' by default).
pair ~sep a b
returns a conv for a list of values separated by sep
(',' by default).
The apply operator in the parlance of applicative functors.
A parser that takes no arguments and returns ()
, included for testing purposes
A parser that resolves to the program name as it appeared on the command line.
Takes a parser of a list and returns a parser that yields the last element of the list. Raises a Parse_error.E
if the list is empty.
val named_multi :
?desc:string ->
?value_name:string ->
?hidden:bool ->
?completion:'a Completion.t ->
string list ->
'a conv ->
'a list t
A named argument that may appear multiple times on the command line.
val named_opt :
?desc:string ->
?value_name:string ->
?hidden:bool ->
?completion:'a Completion.t ->
string list ->
'a conv ->
'a option t
A named argument that may appear at most once on the command line.
val named_with_default :
?desc:string ->
?value_name:string ->
?hidden:bool ->
?completion:'a Completion.t ->
string list ->
'a conv ->
default:'a ->
'a t
A named argument that may appear at most once on the command line. If the argument is not passed then a given default value will be used instead.
val named_req :
?desc:string ->
?value_name:string ->
?hidden:bool ->
?completion:'a Completion.t ->
string list ->
'a conv ->
'a t
A named argument that must appear exactly once on the command line.
A flag that may appear multiple times on the command line. Evaluates to the number of times the flag appeared.
A flag that may appear at most once on the command line.
val pos_opt :
?value_name:string ->
?completion:'a Completion.t ->
int ->
'a conv ->
'a option t
pos_opt i conv
declares an optional anonymous positional argument at position i
(starting at 0).
val pos_with_default :
?value_name:string ->
?completion:'a Completion.t ->
int ->
'a conv ->
default:'a ->
'a t
pos_with_default i conv
declares an optional anonymous positional argument with a default value at position i
(starting at 0).
pos_req i conv
declares a required anonymous positional argument at position i
(starting at 0).
Parses all positional arguments.
val pos_left :
?value_name:string ->
?completion:'a Completion.t ->
int ->
'a conv ->
'a list t
pos_left i conv
parses all positional arguments at positions less than i.
val pos_right :
?value_name:string ->
?completion:'a Completion.t ->
int ->
'a conv ->
'a list t
pos_right i conv
parses all positional arguments at positions greater than i.
Stripped down versions of some functions from the parent module for use in reentrant completion functions. None of the documentation arguments are present as there is no access to documentation for the parsers for these functions. Parsers that would fail when passed multiple times no longer fail under this condition, since any errors encountered during autocompletion will be ignored, and it's more useful to have these functions do something rather than nothing.