package devkit
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=222f8ac131b1d970dab7eeb2714bfd6b9338b88b1082e6e01c136ae19e7eaef4
sha512=c9e6d93e3d21e5530c0f4d5baca51bf1f0a5d19248f8af7678d0665bb5cdf295d7aaaaa3e50eb2e44b8720e55097cc675af4dc8ec45acf9da39feb3eae1405d5
doc/devkit.core/Devkit_core/ExtArg/index.html
Module Devkit_core.ExtArg
Source
include module type of struct include Arg end
type spec = Arg.spec =
| Unit of unit -> unit
(*Call the function with unit argument
*)| Bool of bool -> unit
(*Call the function with a bool argument
*)| Set of bool ref
(*Set the reference to true
*)| Clear of bool ref
(*Set the reference to false
*)| String of string -> unit
(*Call the function with a string argument
*)| Set_string of string ref
(*Set the reference to the string argument
*)| Int of int -> unit
(*Call the function with an int argument
*)| Set_int of int ref
(*Set the reference to the int argument
*)| Float of float -> unit
(*Call the function with a float argument
*)| Set_float of float ref
(*Set the reference to the float argument
*)| Tuple of spec list
(*Take several arguments according to the spec list
*)| Symbol of string list * string -> unit
(*Take one of the symbols as argument and call the function with the symbol
*)| Rest of string -> unit
(*Stop interpreting keywords and call the function with each remaining argument
*)| Rest_all of string list -> unit
(*Stop interpreting keywords and call the function with all remaining arguments
*)| Expand of string -> string array
(*If the remaining arguments to process are of the form
*)["-foo"; "arg"] @ rest
where "foo" is registered asExpand f
, then the argumentsf "arg" @ rest
are processed. Only allowed inparse_and_expand_argv_dynamic
.
The concrete type describing the behavior associated with a keyword.
Same as Arg.parse
, except that the speclist
argument is a reference and may be updated during the parsing. A typical use for this feature is to parse command lines of the form:
- command subcommand
options
where the list of options depends on the value of the subcommand argument.
val parse_argv :
?current:int ref ->
string array ->
(key * spec * doc) list ->
anon_fun ->
usage_msg ->
unit
Arg.parse_argv ~current args speclist anon_fun usage_msg
parses the array args
as if it were the command line. It uses and updates the value of ~current
(if given), or Arg.current
. You must set it before calling parse_argv
. The initial value of current
is the index of the program name (argument 0) in the array. If an error occurs, Arg.parse_argv
raises Arg.Bad
with the error message as argument. If option -help
or --help
is given, Arg.parse_argv
raises Arg.Help
with the help message as argument.
val parse_argv_dynamic :
?current:int ref ->
string array ->
(key * spec * doc) list ref ->
anon_fun ->
string ->
unit
Same as Arg.parse_argv
, except that the speclist
argument is a reference and may be updated during the parsing. See Arg.parse_dynamic
.
val parse_and_expand_argv_dynamic :
int ref ->
string array ref ->
(key * spec * doc) list ref ->
anon_fun ->
string ->
unit
Same as Arg.parse_argv_dynamic
, except that the argv
argument is a reference and may be updated during the parsing of Expand
arguments. See Arg.parse_argv_dynamic
.
Raised by Arg.parse_argv
when the user asks for help.
Functions in spec
or anon_fun
can raise Arg.Bad
with an error message to reject invalid arguments. Arg.Bad
is also raised by Arg.parse_argv
in case of an error.
Returns the message that would have been printed by Arg.usage
, if provided with the same parameters.
Position (in Sys.argv
) of the argument being processed. You can change this value, e.g. to force Arg.parse
to skip some arguments. Arg.parse
uses the initial value of Arg.current
as the index of argument 0 (the program name) and starts parsing arguments at the next element.
Arg.read_arg file
reads newline-terminated command line arguments from file file
.
Identical to Arg.read_arg
but assumes null character terminated command line arguments.
Arg.write_arg file args
writes the arguments args
newline-terminated into the file file
. If the any of the arguments in args
contains a newline, use Arg.write_arg0
instead.
Identical to Arg.write_arg
but uses the null character for terminator instead of newline.
val make_arg :
< kind : string ; show : 'a -> string ; store : 'a -> 'b.. > ->
string ->
'a ->
string ->
string * 'b * string