Arg_complete
Command line argument specifications are extended with completion functions.
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 Stdlib.ref | (* Set the reference to true *) |
| Clear of bool Stdlib.ref | (* Set the reference to false *) |
| String of string -> unit * complete | (* Call the function with a string argument *) |
| Set_string of string Stdlib.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 Stdlib.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 Stdlib.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 |
Command line argument specification like Stdlib
.Arg.spec, but extended with completion functions.
module Rest_all_compat : sig ... end
Compatibility for Rest_all
before OCaml 4.12
type speclist = (Stdlib.Arg.key * spec * Stdlib.Arg.doc) list
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
.
type anon_complete = complete
val complete_argv : 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.
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 : sig ... end