Module RargInternal.Args
type kind
=
;|
Req
Required argument
|
Opt
Optional 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 provide
an arg with this name:
- Provide an arg with this name and
type possibleValues
=
;|
ZeroOrOne
0 or 1 value
|
One
1 value
|
Many
0 or more values
type t
=
{
name: string,
main name of the argument, for example
--foo
alias: option(string),
alternative name of the argument, for example
-f
doc: string,
description to show in the help
type_: string,
for example
bool
string
file
and 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)).