10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-18 20:12:26 +01:00
QCaml/common/lib/command_line.mli
2020-12-27 15:46:11 +01:00

88 lines
2.3 KiB
OCaml

(* Type
*
* - Short option: in the command line, a dash with a single character
* (ex: =ls -l=)
* - Long option: in the command line, two dashes with a word
* (ex: =ls --directory=)
* - Command-line options can be ~Mandatory~ or ~Optional~
* - Documentation of the option is used in the help function
* - Some options require an argument (~ls --ignore="*.ml"~ ), some
* don't (~ls -l~) and for some arguments the argument is optional
* (~git --log[=<n>]~)
*
* #+NAME:type *)
(* [[file:../command_line.org::type][type]] *)
type short_opt = char
type long_opt = string
type optional = Mandatory | Optional
type documentation = string
type argument = With_arg of string | Without_arg | With_opt_arg of string
type description = {
short: short_opt ;
long : long_opt ;
opt : optional ;
doc : documentation ;
arg : argument ;
}
(* type ends here *)
(* Functions to set the header, footer and main description of the
* documentation provided by the ~help~ function: *)
(* [[file:../command_line.org::*Mutable attributes][Mutable attributes:2]] *)
val set_header_doc : string -> unit
val set_description_doc : string -> unit
val set_footer_doc : string -> unit
(* Mutable attributes:2 ends here *)
(* Function to create an anonymous argument: *)
(* [[file:../command_line.org::*Mutable attributes][Mutable attributes:4]] *)
val anonymous : long_opt -> optional -> documentation -> description
(* Mutable attributes:4 ends here *)
(* ~anon_args~
*
* Returns the list of anonymous arguments *)
(* [[file:../command_line.org::*~anon_args~][~anon_args~:1]] *)
val anon_args : unit -> string list
(* ~anon_args~:1 ends here *)
(* ~get~
*
* Returns the argument associated with a long option. *)
(* [[file:../command_line.org::*~get~][~get~:1]] *)
val get : long_opt -> string option
(* ~get~:1 ends here *)
(* ~get_bool~
*
* True if the ~Optional~ argument is present in the command-line *)
(* [[file:../command_line.org::*~get_bool~][~get_bool~:1]] *)
val get_bool : long_opt -> bool
(* ~get_bool~:1 ends here *)
(* Specification
*
* Gives the specifications of the current program as a list of
* ~descrption~ variables. *)
(* [[file:../command_line.org::*Specification][Specification:1]] *)
val set_specs : description list -> unit
(* Specification:1 ends here *)