linol/cmdliner/Cmdliner/Arg/index.html
2025-11-26 00:50:10 +00:00

24 lines
44 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Arg (cmdliner.Cmdliner.Arg)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.1.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../../index.html">Index</a> &#x00BB; <a href="../../index.html">cmdliner</a> &#x00BB; <a href="../index.html">Cmdliner</a> &#x00BB; Arg</nav><header class="odoc-preamble"><h1>Module <code><span>Cmdliner.Arg</span></code></h1><p>Terms for command line arguments.</p><p>This module provides functions to define terms that evaluate to the arguments provided on the command line.</p><p>Basic constraints, like the argument type or repeatability, are specified by defining a value of type <a href="#type-t"><code>Arg.t</code></a>. Further constraints can be specified during the <a href="#argterms" title="argterms">conversion</a> to a term.</p></header><div class="odoc-tocs"><nav class="odoc-toc odoc-local-toc"><ul><li><a href="#argconv">Argument converters</a></li><li><a href="#arginfo">Arguments</a><ul><li><a href="#optargs">Optional arguments</a></li><li><a href="#posargs">Positional arguments</a></li><li><a href="#argterms">Converting to terms</a></li><li><a href="#predef">Predefined arguments</a></li></ul></li><li><a href="#converters">Predefined converters</a><ul><li><a href="#files">Files and directories</a></li></ul></li><li><a href="#doc_helpers">Documentation formatting helpers</a></li><li><a href="#deprecated">Deprecated</a></li></ul></nav></div><div class="odoc-content"><h2 id="argconv"><a href="#argconv" class="anchor"></a>Argument converters</h2><div class="odoc-spec"><div class="spec module anchored" id="module-Completion"><a href="#module-Completion" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Completion/index.html">Completion</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Argument completion.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Conv"><a href="#module-Conv" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Conv/index.html">Conv</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Argument converters.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-conv"><a href="#type-conv" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a conv</span></span><span> = <span><span class="type-var">'a</span> <a href="Conv/index.html#type-t">Conv.t</a></span></span></code></div><div class="spec-doc"><p>The type for argument converters. See the <a href="#predef" title="predef">predefined converters</a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-some'"><a href="#val-some'" class="anchor"></a><code><span><span class="keyword">val</span> some' : <span><span class="optlabel">?none</span>:<span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> option</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>some' ?none c</code> is like the converter <code>c</code> except it returns <code>Some</code> value. It is used for command line arguments that default to <code>None</code> when absent. If provided, <code>none</code> is used with <code>c</code>'s formatter to document the value taken on absence; to document a more complex behaviour use the <code>absent</code> argument of <a href="#val-info"><code>info</code></a>. If you cannot construct an <code>'a</code> value use <a href="#val-some"><code>some</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-some"><a href="#val-some" class="anchor"></a><code><span><span class="keyword">val</span> some : <span><span class="optlabel">?none</span>:string <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> option</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>some ?none c</code> is like <code>some'</code> but <code>none</code> is described as a string that will be rendered in bold. Use the <code>absent</code> argument of <a href="#val-info"><code>info</code></a> to document more complex behaviours.</p></div></div><h2 id="arginfo"><a href="#arginfo" class="anchor"></a>Arguments</h2><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a t</span></span></code></div><div class="spec-doc"><p>The type for arguments holding data of type <code>'a</code>.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-info"><a href="#type-info" class="anchor"></a><code><span><span class="keyword">type</span> info</span></code></div><div class="spec-doc"><p>The type for information about command line arguments.</p><p>Argument information defines the man page information of an argument and, for optional arguments, its names. An environment variable can also be specified to read get the argument value from if the argument is absent from the command line and the variable is defined.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-info"><a href="#val-info" class="anchor"></a><code><span><span class="keyword">val</span> info :
<span><span class="optlabel">?deprecated</span>:string <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?absent</span>:string <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?docs</span>:<a href="../Manpage/index.html#type-section_name">Manpage.section_name</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?doc_envs</span>:<span><a href="../Cmd/Env/index.html#type-info">Cmd.Env.info</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?docv</span>:string <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?doc</span>:string <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?env</span>:<a href="../Cmd/Env/index.html#type-info">Cmd.Env.info</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>string list</span> <span class="arrow">&#45;&gt;</span></span>
<a href="#type-info">info</a></span></code></div><div class="spec-doc"><p><code>info docs docv doc env names</code> defines information for an argument.</p><ul><li><code>names</code> defines the names under which an optional argument can be referred to. Strings of length <code>1</code> like <code>&quot;c&quot;</code>) define short option names <code>&quot;-c&quot;</code>, longer strings like <code>&quot;count&quot;</code>) define long option names <code>&quot;--count&quot;</code>. <code>names</code> must be empty for positional arguments.</li><li><code>env</code> defines the name of an environment variable which is looked up for defining the argument if it is absent from the command line. See <a href="../../cli.html#envlookup" title="envlookup">environment variables</a> for details.</li><li><code>doc</code> is the man page information of the argument. <a href="#doc_helpers" title="doc_helpers">These functions</a> can help with formatting argument values.</li><li><code>docv</code> is for positional and non-flag optional arguments. It is a variable name used in the man page to stand for their value. If unspecified is taken from the argument converter's, see <a href="Conv/index.html#val-docv"><code>Conv.docv</code></a>.</li><li><code>doc_envs</code> is a list of environment variable that are added to the manual of the command when the argument is used.</li><li><code>docs</code> is the title of the man page section in which the argument will be listed. For optional arguments this defaults to <a href="../Manpage/index.html#val-s_options"><code>Manpage.s_options</code></a>. For positional arguments this defaults to <a href="../Manpage/index.html#val-s_arguments"><code>Manpage.s_arguments</code></a>. However a positional argument is only listed if it has both a <code>doc</code> and <code>docv</code> specified.</li><li><code>deprecated</code>, if specified the argument is deprecated. Use of the variable warns on <code>stderr</code>. This message which should be a capitalized sentence is preprended to <code>doc</code> and output on standard error when the environment variable ends up being used.</li><li><code>absent</code>, if specified a documentation string that indicates what happens when the argument is absent. The document language can be used like in <code>doc</code>. This overrides the automatic default value rendering that is performed by the combinators.</li></ul><p>In <code>doc</code>, <code>deprecated</code>, <code>absent</code> the <a href="../../tool_man.html#doclang" title="doclang">documentation markup language</a> can be used with following variables:</p><ul><li><code>&quot;$(docv)&quot;</code> the value of <code>docv</code> (see below).</li><li><code>&quot;$(opt)&quot;</code>, one of the options of <code>names</code>, preference is given to a long one.</li><li><code>&quot;$(env)&quot;</code>, the environment var specified by <code>env</code> (if any).</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(&amp;)"><a href="#val-(&amp;)" class="anchor"></a><code><span><span class="keyword">val</span> (&amp;) : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'b</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'b</span></span></code></div><div class="spec-doc"><p><code>f &amp; v</code> is <code>f v</code>, a right associative composition operator for specifying argument terms.</p></div></div><h3 id="optargs"><a href="#optargs" class="anchor"></a>Optional arguments</h3><p>The <a href="#type-info" title="info">information</a> of an optional argument must have at least one name or <code>Invalid_argument</code> is raised.</p><div class="odoc-spec"><div class="spec value anchored" id="val-flag"><a href="#val-flag" class="anchor"></a><code><span><span class="keyword">val</span> flag : <span><a href="#type-info">info</a> <span class="arrow">&#45;&gt;</span></span> <span>bool <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>flag i</code> is a <code>bool</code> argument defined by an optional flag that may appear <em>at most</em> once on the command line under one of the names specified by <code>i</code>. The argument holds <code>true</code> if the flag is present on the command line and <code>false</code> otherwise.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-flag_all"><a href="#val-flag_all" class="anchor"></a><code><span><span class="keyword">val</span> flag_all : <span><a href="#type-info">info</a> <span class="arrow">&#45;&gt;</span></span> <span><span>bool list</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>flag_all</code> is like <a href="#val-flag"><code>flag</code></a> except the flag may appear more than once. The argument holds a list that contains one <code>true</code> value per occurrence of the flag. It holds the empty list if the flag is absent from the command line.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-vflag"><a href="#val-vflag" class="anchor"></a><code><span><span class="keyword">val</span> vflag : <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span>(<span class="type-var">'a</span> * <a href="#type-info">info</a>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>vflag v [v</code><sub>0</sub><code>,i</code><sub>0</sub><code>;…]</code> is an <code>'a</code> argument defined by an optional flag that may appear <em>at most</em> once on the command line under one of the names specified in the <code>i</code><sub>k</sub> values. The argument holds <code>v</code> if the flag is absent from the command line and the value <code>v</code><sub>k</sub> if the name under which it appears is in <code>i</code><sub>k</sub>.</p><p><b>Note.</b> Automatic environment variable lookup is unsupported for for these arguments but an <code>env</code> in an info will be documented. Use an option and <a href="../Term/index.html#val-env"><code>Term.env</code></a> for manually looking something up.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-vflag_all"><a href="#val-vflag_all" class="anchor"></a><code><span><span class="keyword">val</span> vflag_all : <span><span><span class="type-var">'a</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span>(<span class="type-var">'a</span> * <a href="#type-info">info</a>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>vflag_all v l</code> is like <a href="#val-vflag"><code>vflag</code></a> except the flag may appear more than once. The argument holds the list <code>v</code> if the flag is absent from the command line. Otherwise it holds a list that contains one corresponding value per occurrence of the flag, in the order found on the command line.</p><p><b>Note.</b> Automatic environment variable lookup is unsupported for for these arguments but an <code>env</code> in an info will be documented. Use an option and <a href="../Term/index.html#val-env"><code>Term.env</code></a> for manually looking something up.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-opt"><a href="#val-opt" class="anchor"></a><code><span><span class="keyword">val</span> opt : <span><span class="optlabel">?vopt</span>:<span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-info">info</a> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>opt vopt c v i</code> is an <code>'a</code> argument defined by the value of an optional argument that may appear <em>at most</em> once on the command line under one of the names specified by <code>i</code>. The argument holds <code>v</code> if the option is absent from the command line. Otherwise it has the value of the option as converted by <code>c</code>.</p><p>If <code>vopt</code> is provided the value of the optional argument is itself optional, taking the value <code>vopt</code> if unspecified on the command line. <b>Warning</b> using <code>vopt</code> is <a href="../../cookbook.html#tip_avoid_default_option_values" title="tip_avoid_default_option_values">not recommended</a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-opt_all"><a href="#val-opt_all" class="anchor"></a><code><span><span class="keyword">val</span> opt_all : <span><span class="optlabel">?vopt</span>:<span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-info">info</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>opt_all vopt c v i</code> is like <a href="#val-opt"><code>opt</code></a> except the optional argument may appear more than once. The argument holds a list that contains one value per occurrence of the flag in the order found on the command line. It holds the list <code>v</code> if the flag is absent from the command line.</p></div></div><h3 id="posargs"><a href="#posargs" class="anchor"></a>Positional arguments</h3><p>The <a href="#type-info" title="info">information</a> of a positional argument must have no name or <code>Invalid_argument</code> is raised. Positional arguments indexing is zero-based.</p><p><b>Warning.</b> The following combinators allow to specify and extract a given positional argument with more than one term. This should not be done as it will likely confuse end users and documentation generation. These over-specifications may be prevented by raising <code>Invalid_argument</code> in the future. But for now it is the client's duty to make sure this doesn't happen.</p><div class="odoc-spec"><div class="spec value anchored" id="val-pos"><a href="#val-pos" class="anchor"></a><code><span><span class="keyword">val</span> pos : <span><span class="optlabel">?rev</span>:bool <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-info">info</a> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>pos rev n c v i</code> is an <code>'a</code> argument defined by the <code>n</code>th positional argument of the command line as converted by <code>c</code>. If the positional argument is absent from the command line the argument is <code>v</code>.</p><p>If <code>rev</code> is <code>true</code> (defaults to <code>false</code>), the computed position is <code>max-n</code> where <code>max</code> is the position of the last positional argument present on the command line.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-pos_all"><a href="#val-pos_all" class="anchor"></a><code><span><span class="keyword">val</span> pos_all : <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-info">info</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>pos_all c v i</code> is an <code>'a list</code> argument that holds all the positional arguments of the command line as converted by <code>c</code> or <code>v</code> if there are none.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-pos_left"><a href="#val-pos_left" class="anchor"></a><code><span><span class="keyword">val</span> pos_left : <span><span class="optlabel">?rev</span>:bool <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-info">info</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>pos_left rev n c v i</code> is an <code>'a list</code> argument that holds all the positional arguments as converted by <code>c</code> found on the left of the <code>n</code>th positional argument or <code>v</code> if there are none.</p><p>If <code>rev</code> is <code>true</code> (defaults to <code>false</code>), the computed position is <code>max-n</code> where <code>max</code> is the position of the last positional argument present on the command line.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-pos_right"><a href="#val-pos_right" class="anchor"></a><code><span><span class="keyword">val</span> pos_right : <span><span class="optlabel">?rev</span>:bool <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-info">info</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>pos_right</code> is like <a href="#val-pos_left"><code>pos_left</code></a> except it holds all the positional arguments found on the right of the specified positional argument.</p></div></div><h3 id="argterms"><a href="#argterms" class="anchor"></a>Converting to terms</h3><div class="odoc-spec"><div class="spec value anchored" id="val-value"><a href="#val-value" class="anchor"></a><code><span><span class="keyword">val</span> value : <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="../Term/index.html#type-t">Term.t</a></span></span></code></div><div class="spec-doc"><p><code>value a</code> is a term that evaluates to <code>a</code>'s value.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-required"><a href="#val-required" class="anchor"></a><code><span><span class="keyword">val</span> required : <span><span><span><span class="type-var">'a</span> option</span> <a href="#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="../Term/index.html#type-t">Term.t</a></span></span></code></div><div class="spec-doc"><p><code>required a</code> is a term that fails if <code>a</code>'s value is <code>None</code> and evaluates to the value of <code>Some</code> otherwise. Use this in combination with <a href="#val-some'"><code>Arg.some'</code></a> for required positional arguments. <b>Warning</b> using this on optional arguments is <a href="../../cookbook.html#tip_avoid_required_opt" title="tip_avoid_required_opt">not recommended</a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-non_empty"><a href="#val-non_empty" class="anchor"></a><code><span><span class="keyword">val</span> non_empty : <span><span><span><span class="type-var">'a</span> list</span> <a href="#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <a href="../Term/index.html#type-t">Term.t</a></span></span></code></div><div class="spec-doc"><p><code>non_empty a</code> is term that fails if <code>a</code>'s list is empty and evaluates to <code>a</code>'s list otherwise. Use this for non empty lists of positional arguments.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-last"><a href="#val-last" class="anchor"></a><code><span><span class="keyword">val</span> last : <span><span><span><span class="type-var">'a</span> list</span> <a href="#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="../Term/index.html#type-t">Term.t</a></span></span></code></div><div class="spec-doc"><p><code>last a</code> is a term that fails if <code>a</code>'s list is empty and evaluates to the value of the last element of the list otherwise. Use this for lists of flags or options where the last occurrence takes precedence over the others.</p></div></div><h3 id="predef"><a href="#predef" class="anchor"></a>Predefined arguments</h3><div class="odoc-spec"><div class="spec value anchored" id="val-man_format"><a href="#val-man_format" class="anchor"></a><code><span><span class="keyword">val</span> man_format : <span><a href="../Manpage/index.html#type-format">Manpage.format</a> <a href="../Term/index.html#type-t">Term.t</a></span></span></code></div><div class="spec-doc"><p><code>man_format</code> is a term that defines a <code>--man-format</code> option and evaluates to a value that can be used with <a href="../Manpage/index.html#val-print"><code>Manpage.print</code></a>.</p></div></div><h2 id="converters"><a href="#converters" class="anchor"></a>Predefined converters</h2><div class="odoc-spec"><div class="spec value anchored" id="val-bool"><a href="#val-bool" class="anchor"></a><code><span><span class="keyword">val</span> bool : <span>bool <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>bool</code> converts values with <code>bool_of_string</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-char"><a href="#val-char" class="anchor"></a><code><span><span class="keyword">val</span> char : <span>char <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>char</code> converts values by ensuring the argument has a single char.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-int"><a href="#val-int" class="anchor"></a><code><span><span class="keyword">val</span> int : <span>int <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>int</code> converts values with <code>int_of_string</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-nativeint"><a href="#val-nativeint" class="anchor"></a><code><span><span class="keyword">val</span> nativeint : <span>nativeint <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>nativeint</code> converts values with <code>Nativeint.of_string</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-int32"><a href="#val-int32" class="anchor"></a><code><span><span class="keyword">val</span> int32 : <span>int32 <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>int32</code> converts values with <code>Int32.of_string</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-int64"><a href="#val-int64" class="anchor"></a><code><span><span class="keyword">val</span> int64 : <span>int64 <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>int64</code> converts values with <code>Int64.of_string</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-float"><a href="#val-float" class="anchor"></a><code><span><span class="keyword">val</span> float : <span>float <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>float</code> converts values with <code>float_of_string</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-string"><a href="#val-string" class="anchor"></a><code><span><span class="keyword">val</span> string : <span>string <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>string</code> converts values with the identity function.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-enum"><a href="#val-enum" class="anchor"></a><code><span><span class="keyword">val</span> enum : <span><span class="optlabel">?docv</span>:string <span class="arrow">&#45;&gt;</span></span> <span><span><span>(string * <span class="type-var">'a</span>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>enum l p</code> converts values such that string names in <code>l</code> map to the corresponding value of type <code>'a</code>. <code>docv</code> is the converter's documentation meta-variable, it defaults to <code>ENUM</code>. A <a href="Completion/index.html#val-make" title="Completion.make">completion</a> is added for the names.</p><p><b>Warning.</b> The type <code>'a</code> must be comparable with <a href="../../../ocaml/Stdlib/index.html#val-compare"><code>Stdlib.compare</code></a>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <code>Invalid_argument</code> <p>if <code>l</code> is empty.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-list"><a href="#val-list" class="anchor"></a><code><span><span class="keyword">val</span> list : <span><span class="optlabel">?sep</span>:char <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> list</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>list sep c</code> splits the argument at each <code>sep</code> (defaults to <code>','</code>) character and converts each substrings with <code>c</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-array"><a href="#val-array" class="anchor"></a><code><span><span class="keyword">val</span> array : <span><span class="optlabel">?sep</span>:char <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> array</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>array sep c</code> splits the argument at each <code>sep</code> (defaults to <code>','</code>) character and converts each substring with <code>c</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-pair"><a href="#val-pair" class="anchor"></a><code><span><span class="keyword">val</span> pair : <span><span class="optlabel">?sep</span>:char <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'b</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>pair sep c0 c1</code> splits the argument at the <em>first</em> <code>sep</code> character (defaults to <code>','</code>) and respectively converts the substrings with <code>c0</code> and <code>c1</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-t2"><a href="#val-t2" class="anchor"></a><code><span><span class="keyword">val</span> t2 : <span><span class="optlabel">?sep</span>:char <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'b</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><a href="#val-t2"><code>t2</code></a> is <a href="#val-pair"><code>pair</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-t3"><a href="#val-t3" class="anchor"></a><code><span><span class="keyword">val</span> t3 : <span><span class="optlabel">?sep</span>:char <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'b</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'c</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span> * <span class="type-var">'c</span>)</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>t3 sep c0 c1 c2</code> splits the argument at the <em>first</em> two <code>sep</code> characters (defaults to <code>','</code>) and respectively converts the substrings with <code>c0</code>, <code>c1</code> and <code>c2</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-t4"><a href="#val-t4" class="anchor"></a><code><span><span class="keyword">val</span> t4 :
<span><span class="optlabel">?sep</span>:char <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'b</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'c</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'d</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span> * <span class="type-var">'c</span> * <span class="type-var">'d</span>)</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>t4 sep c0 c1 c2 c3</code> splits the argument at the <em>first</em> three <code>sep</code> characters (defaults to <code>','</code>) respectively converts the substrings with <code>c0</code>, <code>c1</code>, <code>c2</code> and <code>c3</code>.</p></div></div><h3 id="files"><a href="#files" class="anchor"></a>Files and directories</h3><div class="odoc-spec"><div class="spec value anchored" id="val-path"><a href="#val-path" class="anchor"></a><code><span><span class="keyword">val</span> path : <span>string <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>path</code> is like <a href="#val-string"><code>string</code></a> but prints using <code>Filename.quote</code> and completes both files and directories.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-filepath"><a href="#val-filepath" class="anchor"></a><code><span><span class="keyword">val</span> filepath : <span>string <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>filepath</code> is like <a href="#val-string"><code>string</code></a> but prints using <code>Filename.quote</code> and completes files.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-dirpath"><a href="#val-dirpath" class="anchor"></a><code><span><span class="keyword">val</span> dirpath : <span>string <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>dirpath</code> is like <a href="#val-string"><code>string</code></a> but prints using <code>Filename.quote</code> and completes directories.</p></div></div><p><b>Note.</b> The following converters report errors whenever the requested file system object does not exist. This is only mildly useful since nothing guarantees they will still exist at the time you act upon them. So you will have to treat these error cases anyways in your tool function. It is also unhelpful if the file system object may be created by your tool. Rather use <a href="#val-filepath"><code>filepath</code></a> and <a href="#val-dirpath"><code>dirpath</code></a>.</p><div class="odoc-spec"><div class="spec value anchored" id="val-file"><a href="#val-file" class="anchor"></a><code><span><span class="keyword">val</span> file : <span>string <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>file</code> converts a value with the identity function and checks with <code>Sys.file_exists</code> that a file with that name exists. The string <code>&quot;-&quot;</code> is parsed without checking: it represents <code>stdio</code>. It completes both files directories.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-dir"><a href="#val-dir" class="anchor"></a><code><span><span class="keyword">val</span> dir : <span>string <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>dir</code> converts a value with the identity function and checks with <code>Sys.file_exists</code> and <code>Sys.is_directory</code> that a directory with that name exists. It completes directories.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-non_dir_file"><a href="#val-non_dir_file" class="anchor"></a><code><span><span class="keyword">val</span> non_dir_file : <span>string <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p><code>non_dir_file</code> converts a value with the identity function and checks with <code>Sys.file_exists</code> and <code>Sys.is_directory</code> that a non directory file with that name exists. The string <code>&quot;-&quot;</code> is parsed without checking it represents <code>stdio</code>. It completes files.</p></div></div><h2 id="doc_helpers"><a href="#doc_helpers" class="anchor"></a>Documentation formatting helpers</h2><div class="odoc-spec"><div class="spec value anchored" id="val-doc_quote"><a href="#val-doc_quote" class="anchor"></a><code><span><span class="keyword">val</span> doc_quote : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>doc_quote s</code> quotes the string <code>s</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-doc_alts"><a href="#val-doc_alts" class="anchor"></a><code><span><span class="keyword">val</span> doc_alts : <span><span class="optlabel">?quoted</span>:bool <span class="arrow">&#45;&gt;</span></span> <span><span>string list</span> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>doc_alts alts</code> documents the alternative tokens <code>alts</code> according the number of alternatives. If <code>quoted</code> is:</p><ul><li><code>None</code>, the tokens are enclosed in manpage markup directives to render them in bold (manpage convention).</li><li><code>Some true</code>, the tokens are quoted with <a href="#val-doc_quote"><code>doc_quote</code></a>.</li><li><code>Some false</code>, the tokens are written as is</li></ul><p>The resulting string can be used in sentences of the form <code>&quot;$(docv) must be %s&quot;</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <code>Invalid_argument</code> <p>if <code>alts</code> is the empty list.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-doc_alts_enum"><a href="#val-doc_alts_enum" class="anchor"></a><code><span><span class="keyword">val</span> doc_alts_enum : <span><span class="optlabel">?quoted</span>:bool <span class="arrow">&#45;&gt;</span></span> <span><span><span>(string * <span class="type-var">'a</span>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>doc_alts_enum quoted alts</code> is <code>doc_alts quoted (List.map fst alts)</code>.</p></div></div><h2 id="deprecated"><a href="#deprecated" class="anchor"></a>Deprecated</h2><p>These identifiers are silently deprecated. For now there is no plan to remove them. But you should prefer to use the <a href="Conv/index.html"><code>Conv</code></a> interface in new code.</p><div class="odoc-spec"><div class="spec type anchored" id="type-printer"><a href="#type-printer" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a printer</span></span><span> = <span><span class="type-var">'a</span> <a href="Conv/index.html#type-fmt">Conv.fmt</a></span></span></code></div><div class="spec-doc"><p>Deprecated. Use <a href="Conv/index.html#type-fmt"><code>Conv.fmt</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-conv'"><a href="#val-conv'" class="anchor"></a><code><span><span class="keyword">val</span> conv' : <span><span class="optlabel">?docv</span>:string <span class="arrow">&#45;&gt;</span></span> <span><span>(<span><span class="type-var">'a</span> <a href="Conv/index.html#type-parser">Conv.parser</a></span> * <span><span class="type-var">'a</span> <a href="Conv/index.html#type-fmt">Conv.fmt</a></span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p>Deprecated. Use <a href="Conv/index.html#val-make"><code>Conv.make</code></a> instead.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-conv"><a href="#val-conv" class="anchor"></a><code><span><span class="keyword">val</span> conv :
<span><span class="optlabel">?docv</span>:string <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span>(<span>string <span class="arrow">&#45;&gt;</span></span> <span><span>(<span class="type-var">'a</span>, <span>[ <span>`Msg of string</span> ]</span>)</span> <a href="../../../ocaml/Stdlib/index.html#type-result">result</a></span>)</span> * <span><span class="type-var">'a</span> <a href="Conv/index.html#type-fmt">Conv.fmt</a></span>)</span> <span class="arrow">&#45;&gt;</span></span>
<span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span></span></code></div><div class="spec-doc"><p>Deprecated. Use <a href="Conv/index.html#val-make"><code>Conv.make</code></a> instead.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-conv_parser"><a href="#val-conv_parser" class="anchor"></a><code><span><span class="keyword">val</span> conv_parser : <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span><span>(<span class="type-var">'a</span>, <span>[ <span>`Msg of string</span> ]</span>)</span> <a href="../../../ocaml/Stdlib/index.html#type-result">result</a></span></span></code></div><div class="spec-doc"><p>Deprecated. Use <a href="Conv/index.html#val-parser"><code>Conv.parser</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-conv_printer"><a href="#val-conv_printer" class="anchor"></a><code><span><span class="keyword">val</span> conv_printer : <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="Conv/index.html#type-fmt">Conv.fmt</a></span></span></code></div><div class="spec-doc"><p>Deprecated. Use <a href="Conv/index.html#val-pp"><code>Conv.pp</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-conv_docv"><a href="#val-conv_docv" class="anchor"></a><code><span><span class="keyword">val</span> conv_docv : <span><span><span class="type-var">'a</span> <a href="#type-conv">conv</a></span> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Deprecated. Use <a href="Conv/index.html#val-docv"><code>Conv.docv</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parser_of_kind_of_string"><a href="#val-parser_of_kind_of_string" class="anchor"></a><code><span><span class="keyword">val</span> parser_of_kind_of_string :
<span><span class="label">kind</span>:string <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span>string <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> option</span>)</span> <span class="arrow">&#45;&gt;</span></span>
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span class="type-var">'a</span>, <span>[ <span>`Msg of string</span> ]</span>)</span> <a href="../../../ocaml/Stdlib/index.html#type-result">result</a></span></span></code></div><div class="spec-doc"><p>Deprecated. <code>parser_of_kind_of_string ~kind kind_of_string</code> is an argument parser using the <code>kind_of_string</code> function for parsing and <code>kind</code> to report errors (e.g. could be <code>&quot;an integer&quot;</code> for an <code>int</code> parser.).</p></div></div></div></body></html>