package mopsa
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=37966e98ffeebcedc09bd6e9b2b81f69
sha512=40d4d826c25f680766c07eccbabdf5e8a4fa023016e8a164e4e4f6b3781c8484dc4df437055721dfd19b9db8fb7fe3b61236c4833186d346fc7204a68d01eaaa
doc/mopsa.mopsa_utils/Mopsa_utils/Core/ArgExt/index.html
Module Core.ArgExt
include module type of struct include Arg_complete end
Specification
Command line argument specifications are extended with completion functions.
Type for function providing multiple-argument completions (only in Rest_all
).
type spec = Arg_complete.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 * complete
(*Call the function with a string argument
*)| Set_string of string ref * complete
(*Set the reference to the string argument
*)| Int of int -> unit * complete
(*Call the function with an int argument
*)| Set_int of int ref * complete
(*Set the reference to the int argument
*)| Float of float -> unit * complete
(*Call the function with a float argument
*)| Set_float of float ref * complete
(*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 * complete
(*Stop interpreting keywords and call the function with each remaining argument
*)| Rest_all of string list -> unit * complete_all
(*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 inStdlib.Arg.parse_and_expand_argv_dynamic
.
Command line argument specification like Stdlib.Arg.spec
, but extended with completion functions.
module Rest_all_compat = Arg_complete.Rest_all_compat
Compatibility for Rest_all
before OCaml 4.12
Parsing
The library does not provide parsing of command line arguments itself. Instead, the following functions can be used to strip completion functions from specifications, such that parsing functions from Stdlib.Arg
can be used.
val arg_speclist : speclist -> arg_speclist
Strip completion functions from speclist
.
Completing
type anon_complete = complete
val complete_argv :
?prefer_getopt_long:bool ->
string list ->
speclist ->
anon_complete ->
string list
complete_argv args speclist anon_complete
provides the completions for the partial arguments args
using speclist
for options and anon_complete
for anonymous arguments.
Convenience
val empty : complete
Completion function with constant empty result.
val empty_all : complete_all
Completion function with constant empty result for Rest_all
.
val strings : string list -> complete
Completion function for a list of possible strings.
module Util = Arg_complete.Util
val set_string_list_lifter : string list ref -> string -> unit
val complete_files_in_dir : ?prefix:string -> string -> complete