package arg-complete
Module Arg_completeSource
Specification
Command line argument specifications are extended with completion functions.
Type for function providing single-argument completions.
Type for function providing multiple-argument completions (only in Rest_all).
type 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"] @ restwhere "foo" is registered asExpand f, then the argumentsf "arg" @ restare processed. Only allowed inStdlib.Arg.parse_and_expand_argv_dynamic.
Command line argument specification like Stdlib.Arg.spec, but extended with completion functions.
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.
Strip completion functions from speclist.
Completing
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
Completion function with constant empty result for Rest_all.