package reason
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=a58837f14a79f047c8eb99d5518aeb16ee64353574286cfd5b284c98a1a27250
    
    
  sha512=28d6d1c3636e400614b1a7d8c78b0bbb5de143e259edf683139b75d2fd2013da8e1a6c58d11047e6853f1e559c387d233570665de0de646005197b5f4d6f4879
    
    
  doc/reason.cmdliner/Vendored_cmdliner/Term/index.html
Module Vendored_cmdliner.TermSource
Terms.
A term is evaluated by a program to produce a result. A term made of terms referring to command line arguments implicitly defines a command line syntax.
Terms
The type for terms evaluating to values of type 'a.
f $ v is a term that evaluates to the result of applying the evaluation of v to the one of f.
ret v is a term whose evaluation depends on the case to which v evaluates. With :
- `Ok r, it evaluates to- r.
- `Error (usage,e), the evaluation fails and- Cmdlinerprints the error- eand the term's usage if- usageis- true.
- `Help (format, name), the evaluation fails and- Cmdlinerprints the term's man page in the given- format(or the man page for a specific- nameterm in case of multiple term evaluation).
choice_names is a term that evaluates to the names of the terms to choose from.
man_format is a term that defines a --man-format option and evaluates to a value that can be used with Manpage.print.
Term information
Term information defines the name and man page of a term. For simple evaluation this is the name of the program and its man page. For multiple term evaluation, this is the name of a command and its man page.
The type for term information.
val info : 
  ?sdocs:string ->
  ?man:Manpage.block list ->
  ?docs:string ->
  ?doc:string ->
  ?version:string ->
  string ->
  infoinfo sdocs man docs doc version name is a term information such that:
- nameis the name of the program or the command.
- versionis the version string of the program, ignored for commands.
- docis a one line description of the program or command used for the- NAMEsection of the term's man page. For commands this description is also used in the list of commands of the main term's man page.
- docs, only for commands, the title of the section of the main term's man page where it should be listed (defaults to- "COMMANDS").
- manis the text of the man page for the term. In the text, the variables- "$(tname)"and- "$(mname)"can respectively be used to refer to the value of- nameand the main term's name.
- sdocsdefines the title of the section in which the standard- --helpand- --versionarguments are listed.
Evaluation
The type for evaluation results.
- `Ok v, the term evaluated successfully and- vis the result.
- `Version, the version string of the main term was printed on the help formatter.
- `Help, man page about the term was printed on the help formatter.
- `Error `Parse, a command line parse error occured and was reported on the error formatter.
- `Error `Term, a term evaluation error occured and was reported on the error formatter (see- Term.ret).
- `Error `Exn, an exception- ewas caught and reported on the error formatter (see the- ~catchparameter of- eval).
val eval : 
  ?help:Format.formatter ->
  ?err:Format.formatter ->
  ?catch:bool ->
  ?env:(string -> string option) ->
  ?argv:string array ->
  ('a t * info) ->
  'a resulteval help err catch argv (t,i) is the evaluation result of t with command line arguments argv (defaults to Sys.argv).
If catch is true (default) uncaught exeptions are intercepted and their stack trace is written to the err formatter.
help is the formatter used to print help or version messages (defaults to Format.std_formatter). err is the formatter used to print error messages (defaults to Format.err_formatter).
env is used for environment variable lookup, the default uses Sys.getenv.
val eval_choice : 
  ?help:Format.formatter ->
  ?err:Format.formatter ->
  ?catch:bool ->
  ?env:(string -> string option) ->
  ?argv:string array ->
  ('a t * info) ->
  ('a t * info) list ->
  'a resulteval_choice help err catch argv default (t,i) choices is like eval except that if the first argument on the command line is not an option name it will look in choices for a term whose information has this name and evaluate it.
If the command name is unknown an error is reported. If the name is unspecified the "main" term t is evaluated. i defines the name and man page of the program.
val eval_peek_opts : 
  ?version_opt:bool ->
  ?env:(string -> string option) ->
  ?argv:string array ->
  'a t ->
  'a option * 'a resulteval_peek_opts version_opt argv t evaluates t, a term made of optional arguments only, with the command line argv (defaults to Sys.argv). In this evaluation, unknown optional arguments and positional arguments are ignored.
The evaluation returns a pair. The first component is the result of parsing the command line argv stripped from any help and version option if version_opt is true (defaults to false). It results in:
- Some _if the command line would be parsed correctly given the partial knowledge in- t.
- Noneif a parse error would occur on the options of- t
The second component is the result of parsing the command line argv without stripping the help and version options. It indicates what the evaluation would result in on argv given the partial knowledge in t (for example it would return `Help if there's a help option in argv). However in contrasts to eval and eval_choice no side effects like error reporting or help output occurs.
Note. Positional arguments can't be peeked without the full specification of the command line: we can't tell apart a positional argument from the value of an unknown optional argument.