Module RargInternal.Args
type kind=
;|ReqRequired argument
|OptOptional argument
|OptDefault(string)Optional argument with default value
Arguments definition and validation.
Scenarios used in the examples:
- Provide an arg with this name and
no values:--foo - Provide an arg with this name and
exactly 1 value:--foo value - Provide an arg with this name and
more than 1 value:--foo value1 value2 Don't providean arg with this name:
- Provide an arg with this name and
type possibleValues=
;|ZeroOrOne0 or 1 value
|One1 value
|Many0 or more values
type t={name: string,main name of the argument, for example
--fooalias: option(string),alternative name of the argument, for example
-fdoc: string,description to show in the help
type_: string,for example
boolstringfileand etc. (shown in the help)possibleValues: possibleValues,required values count
kind: kind,whether the argument is required or not
choices: option(Type.Choices.t(string)),possible values for the argument, used only in help and suggestions, not for validation
};An argument definition. It contains everything needed for displaying comprehensive help, argument signature and automatic autocompletion.
type validate= ArgsMap.t => Stdlib.result(unit, ValidateArgs.Err.t);A function for validating an argument (including its
Type, the count of expected values and etc.)
type argValidateTuple('a)= (list((t, validate)), (ArgsMap.t => 'a));A tuple that contains: (a list of arguments, a value getter)
let splitPositionalsAndOptionArgs: list((t, 'a)) => (option(t), list(t));Separates the positionals and options from an arguments list
module One: { ... };
module Many: { ... };
module Positional: { ... };Positional (anonymous) argument (you can have only one definition for positional argument(s)).