<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="Start" href="index.html"> <link rel="next" href="Arg_helper.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Arg" rel="Chapter" href="Arg.html"> <link title="Arg_helper" rel="Chapter" href="Arg_helper.html"> <link title="Array" rel="Chapter" href="Array.html"> <link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html"> <link title="Ast_helper" rel="Chapter" href="Ast_helper.html"> <link title="Ast_invariants" rel="Chapter" href="Ast_invariants.html"> <link title="Ast_iterator" rel="Chapter" href="Ast_iterator.html"> <link title="Ast_mapper" rel="Chapter" href="Ast_mapper.html"> <link title="Asttypes" rel="Chapter" href="Asttypes.html"> <link title="Attr_helper" rel="Chapter" href="Attr_helper.html"> <link title="Bigarray" rel="Chapter" href="Bigarray.html"> <link title="Buffer" rel="Chapter" href="Buffer.html"> <link title="Build_path_prefix_map" rel="Chapter" href="Build_path_prefix_map.html"> <link title="Builtin_attributes" rel="Chapter" href="Builtin_attributes.html"> <link title="Bytes" rel="Chapter" href="Bytes.html"> <link title="BytesLabels" rel="Chapter" href="BytesLabels.html"> <link title="Callback" rel="Chapter" href="Callback.html"> <link title="CamlinternalFormat" rel="Chapter" href="CamlinternalFormat.html"> <link title="CamlinternalFormatBasics" rel="Chapter" href="CamlinternalFormatBasics.html"> <link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html"> <link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html"> <link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html"> <link title="Ccomp" rel="Chapter" href="Ccomp.html"> <link title="Char" rel="Chapter" href="Char.html"> <link title="Clflags" rel="Chapter" href="Clflags.html"> <link title="Complex" rel="Chapter" href="Complex.html"> <link title="Condition" rel="Chapter" href="Condition.html"> <link title="Config" rel="Chapter" href="Config.html"> <link title="Consistbl" rel="Chapter" href="Consistbl.html"> <link title="Depend" rel="Chapter" href="Depend.html"> <link title="Digest" rel="Chapter" href="Digest.html"> <link title="Docstrings" rel="Chapter" href="Docstrings.html"> <link title="Dynlink" rel="Chapter" href="Dynlink.html"> <link title="Ephemeron" rel="Chapter" href="Ephemeron.html"> <link title="Event" rel="Chapter" href="Event.html"> <link title="Filename" rel="Chapter" href="Filename.html"> <link title="Float" rel="Chapter" href="Float.html"> <link title="Format" rel="Chapter" href="Format.html"> <link title="Gc" rel="Chapter" href="Gc.html"> <link title="Genlex" rel="Chapter" href="Genlex.html"> <link title="Graphics" rel="Chapter" href="Graphics.html"> <link title="GraphicsX11" rel="Chapter" href="GraphicsX11.html"> <link title="Hashtbl" rel="Chapter" href="Hashtbl.html"> <link title="Identifiable" rel="Chapter" href="Identifiable.html"> <link title="Int32" rel="Chapter" href="Int32.html"> <link title="Int64" rel="Chapter" href="Int64.html"> <link title="Lazy" rel="Chapter" href="Lazy.html"> <link title="Lexer" rel="Chapter" href="Lexer.html"> <link title="Lexing" rel="Chapter" href="Lexing.html"> <link title="List" rel="Chapter" href="List.html"> <link title="ListLabels" rel="Chapter" href="ListLabels.html"> <link title="Location" rel="Chapter" href="Location.html"> <link title="Longident" rel="Chapter" href="Longident.html"> <link title="Map" rel="Chapter" href="Map.html"> <link title="Marshal" rel="Chapter" href="Marshal.html"> <link title="Misc" rel="Chapter" href="Misc.html"> <link title="MoreLabels" rel="Chapter" href="MoreLabels.html"> <link title="Mutex" rel="Chapter" href="Mutex.html"> <link title="Nativeint" rel="Chapter" href="Nativeint.html"> <link title="Numbers" rel="Chapter" href="Numbers.html"> <link title="Obj" rel="Chapter" href="Obj.html"> <link title="Oo" rel="Chapter" href="Oo.html"> <link title="Parse" rel="Chapter" href="Parse.html"> <link title="Parser" rel="Chapter" href="Parser.html"> <link title="Parsetree" rel="Chapter" href="Parsetree.html"> <link title="Parsing" rel="Chapter" href="Parsing.html"> <link title="Pervasives" rel="Chapter" href="Pervasives.html"> <link title="Pparse" rel="Chapter" href="Pparse.html"> <link title="Pprintast" rel="Chapter" href="Pprintast.html"> <link title="Printast" rel="Chapter" href="Printast.html"> <link title="Printexc" rel="Chapter" href="Printexc.html"> <link title="Printf" rel="Chapter" href="Printf.html"> <link title="Profile" rel="Chapter" href="Profile.html"> <link title="Queue" rel="Chapter" href="Queue.html"> <link title="Random" rel="Chapter" href="Random.html"> <link title="Scanf" rel="Chapter" href="Scanf.html"> <link title="Seq" rel="Chapter" href="Seq.html"> <link title="Set" rel="Chapter" href="Set.html"> <link title="Simplif" rel="Chapter" href="Simplif.html"> <link title="Sort" rel="Chapter" href="Sort.html"> <link title="Spacetime" rel="Chapter" href="Spacetime.html"> <link title="Stack" rel="Chapter" href="Stack.html"> <link title="StdLabels" rel="Chapter" href="StdLabels.html"> <link title="Str" rel="Chapter" href="Str.html"> <link title="Stream" rel="Chapter" href="Stream.html"> <link title="String" rel="Chapter" href="String.html"> <link title="StringLabels" rel="Chapter" href="StringLabels.html"> <link title="Strongly_connected_components" rel="Chapter" href="Strongly_connected_components.html"> <link title="Syntaxerr" rel="Chapter" href="Syntaxerr.html"> <link title="Sys" rel="Chapter" href="Sys.html"> <link title="Targetint" rel="Chapter" href="Targetint.html"> <link title="Tbl" rel="Chapter" href="Tbl.html"> <link title="Terminfo" rel="Chapter" href="Terminfo.html"> <link title="Thread" rel="Chapter" href="Thread.html"> <link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html"> <link title="Typemod" rel="Chapter" href="Typemod.html"> <link title="Uchar" rel="Chapter" href="Uchar.html"> <link title="Unix" rel="Chapter" href="Unix.html"> <link title="UnixLabels" rel="Chapter" href="UnixLabels.html"> <link title="Warnings" rel="Chapter" href="Warnings.html"> <link title="Weak" rel="Chapter" href="Weak.html"><title>Arg</title> </head> <body> <div class="navbar"> <a class="up" href="index.html" title="Index">Up</a> <a class="post" href="Arg_helper.html" title="Arg_helper">Next</a> </div> <h1>Module <a href="type_Arg.html">Arg</a></h1> <pre><span id="MODULEArg"><span class="keyword">module</span> Arg</span>: <code class="code"><span class="keyword">sig</span></code> <a href="Arg.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top"> <div class="info-desc"> <p>Parsing of command line arguments.</p> <p>This module provides a general mechanism for extracting options and arguments from the command line to the program.</p> <p>Syntax of command lines: A keyword is a character string starting with a <code class="code">-</code>. An option is a keyword alone or followed by an argument. The types of keywords are: <code class="code"><span class="constructor">Unit</span></code>, <code class="code"><span class="constructor">Bool</span></code>, <code class="code"><span class="constructor">Set</span></code>, <code class="code"><span class="constructor">Clear</span></code>, <code class="code"><span class="constructor">String</span></code>, <code class="code"><span class="constructor">Set_string</span></code>, <code class="code"><span class="constructor">Int</span></code>, <code class="code"><span class="constructor">Set_int</span></code>, <code class="code"><span class="constructor">Float</span></code>, <code class="code"><span class="constructor">Set_float</span></code>, <code class="code"><span class="constructor">Tuple</span></code>, <code class="code"><span class="constructor">Symbol</span></code>, and <code class="code"><span class="constructor">Rest</span></code>. <code class="code"><span class="constructor">Unit</span></code>, <code class="code"><span class="constructor">Set</span></code> and <code class="code"><span class="constructor">Clear</span></code> keywords take no argument. A <code class="code"><span class="constructor">Rest</span></code> keyword takes the remaining of the command line as arguments. Every other keyword takes the following word on the command line as argument. For compatibility with GNU getopt_long, <code class="code">keyword=arg</code> is also allowed. Arguments not preceded by a keyword are called anonymous arguments.</p> <p>Examples (<code class="code">cmd</code> is assumed to be the command name):</p> <ul> <li> <code class="code">cmd -flag </code>(a unit option)</li> <li> <code class="code">cmd -int 1 </code>(an int option with argument <code class="code">1</code>)</li> <li> <code class="code">cmd -string foobar </code>(a string option with argument <code class="code"><span class="string">"foobar"</span></code>)</li> <li> <code class="code">cmd -float 12.34 </code>(a float option with argument <code class="code">12.34</code>)</li> <li> <code class="code">cmd a b c </code>(three anonymous arguments: <code class="code"><span class="string">"a"</span></code>, <code class="code"><span class="string">"b"</span></code>, and <code class="code"><span class="string">"c"</span></code>)</li> <li> <code class="code">cmd a b -- c d </code>(two anonymous arguments and a rest option with two arguments)</li> </ul> </div> </div> <hr width="100%"> <pre><code><span id="TYPEspec"><span class="keyword">type</span> <code class="type"></code>spec</span> = </code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Unit"><span class="constructor">Unit</span></span> <span class="keyword">of</span> <code class="type">(unit -> unit)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Call the function with unit argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Bool"><span class="constructor">Bool</span></span> <span class="keyword">of</span> <code class="type">(bool -> unit)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Call the function with a bool argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Set"><span class="constructor">Set</span></span> <span class="keyword">of</span> <code class="type">bool <a href="Pervasives.html#TYPEref">ref</a></code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Set the reference to true</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Clear"><span class="constructor">Clear</span></span> <span class="keyword">of</span> <code class="type">bool <a href="Pervasives.html#TYPEref">ref</a></code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Set the reference to false</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.String"><span class="constructor">String</span></span> <span class="keyword">of</span> <code class="type">(string -> unit)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Call the function with a string argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Set_string"><span class="constructor">Set_string</span></span> <span class="keyword">of</span> <code class="type">string <a href="Pervasives.html#TYPEref">ref</a></code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Set the reference to the string argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Int"><span class="constructor">Int</span></span> <span class="keyword">of</span> <code class="type">(int -> unit)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Call the function with an int argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Set_int"><span class="constructor">Set_int</span></span> <span class="keyword">of</span> <code class="type">int <a href="Pervasives.html#TYPEref">ref</a></code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Set the reference to the int argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Float"><span class="constructor">Float</span></span> <span class="keyword">of</span> <code class="type">(float -> unit)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Call the function with a float argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Set_float"><span class="constructor">Set_float</span></span> <span class="keyword">of</span> <code class="type">float <a href="Pervasives.html#TYPEref">ref</a></code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Set the reference to the float argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Tuple"><span class="constructor">Tuple</span></span> <span class="keyword">of</span> <code class="type"><a href="Arg.html#TYPEspec">spec</a> list</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Take several arguments according to the spec list</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Symbol"><span class="constructor">Symbol</span></span> <span class="keyword">of</span> <code class="type">string list * (string -> unit)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Take one of the symbols as argument and call the function with the symbol</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Rest"><span class="constructor">Rest</span></span> <span class="keyword">of</span> <code class="type">(string -> unit)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>Stop interpreting keywords and call the function with each remaining argument</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTspec.Expand"><span class="constructor">Expand</span></span> <span class="keyword">of</span> <code class="type">(string -> string array)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info "> <div class="info-desc"> <p>If the remaining arguments to process are of the form <code class="code">[<span class="string">"-foo"</span>; <span class="string">"arg"</span>] @ rest</code> where "foo" is registered as <code class="code"><span class="constructor">Expand</span> f</code>, then the arguments <code class="code">f <span class="string">"arg"</span> @ rest</code> are processed. Only allowed in <code class="code">parse_and_expand_argv_dynamic</code>.</p> </div> </div> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <div class="info "> <div class="info-desc"> <p>The concrete type describing the behavior associated with a keyword.</p> </div> </div> <pre><span id="TYPEkey"><span class="keyword">type</span> <code class="type"></code>key</span> = <code class="type">string</code> </pre> <pre><span id="TYPEdoc"><span class="keyword">type</span> <code class="type"></code>doc</span> = <code class="type">string</code> </pre> <pre><span id="TYPEusage_msg"><span class="keyword">type</span> <code class="type"></code>usage_msg</span> = <code class="type">string</code> </pre> <pre><span id="TYPEanon_fun"><span class="keyword">type</span> <code class="type"></code>anon_fun</span> = <code class="type">string -> unit</code> </pre> <pre><span id="VALparse"><span class="keyword">val</span> parse</span> : <code class="type">(<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list -> <a href="Arg.html#TYPEanon_fun">anon_fun</a> -> <a href="Arg.html#TYPEusage_msg">usage_msg</a> -> unit</code></pre><div class="info "> <div class="info-desc"> <p><code class="code"><span class="constructor">Arg</span>.parse speclist anon_fun usage_msg</code> parses the command line. <code class="code">speclist</code> is a list of triples <code class="code">(key, spec, doc)</code>. <code class="code">key</code> is the option keyword, it must start with a <code class="code"><span class="string">'-'</span></code> character. <code class="code">spec</code> gives the option type and the function to call when this option is found on the command line. <code class="code">doc</code> is a one-line description of this option. <code class="code">anon_fun</code> is called on anonymous arguments. The functions in <code class="code">spec</code> and <code class="code">anon_fun</code> are called in the same order as their arguments appear on the command line.</p> <p>If an error occurs, <code class="code"><span class="constructor">Arg</span>.parse</code> exits the program, after printing to standard error an error message as follows:</p> <ul> <li> The reason for the error: unknown option, invalid or missing argument, etc.</li> <li> <code class="code">usage_msg</code></li> <li> The list of options, each followed by the corresponding <code class="code">doc</code> string. Beware: options that have an empty <code class="code">doc</code> string will not be included in the list.</li> </ul> <p>For the user to be able to specify anonymous arguments starting with a <code class="code">-</code>, include for example <code class="code">(<span class="string">"-"</span>, <span class="constructor">String</span> anon_fun, doc)</code> in <code class="code">speclist</code>.</p> <p>By default, <code class="code">parse</code> recognizes two unit options, <code class="code">-help</code> and <code class="code">--help</code>, which will print to standard output <code class="code">usage_msg</code> and the list of options, and exit the program. You can override this behaviour by specifying your own <code class="code">-help</code> and <code class="code">--help</code> options in <code class="code">speclist</code>.</p> </div> </div> <pre><span id="VALparse_dynamic"><span class="keyword">val</span> parse_dynamic</span> : <code class="type">(<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list <a href="Pervasives.html#TYPEref">ref</a> -><br> <a href="Arg.html#TYPEanon_fun">anon_fun</a> -> <a href="Arg.html#TYPEusage_msg">usage_msg</a> -> unit</code></pre><div class="info "> <div class="info-desc"> <p>Same as <a href="Arg.html#VALparse"><code class="code"><span class="constructor">Arg</span>.parse</code></a>, except that the <code class="code">speclist</code> argument is a reference and may be updated during the parsing. A typical use for this feature is to parse command lines of the form:</p> <ul> <li> command subcommand <code class="code">options</code> where the list of options depends on the value of the subcommand argument.</li> </ul> </div> <ul class="info-attributes"> <li><b>Since</b> 4.01.0</li> </ul> </div> <pre><span id="VALparse_argv"><span class="keyword">val</span> parse_argv</span> : <code class="type">?current:int <a href="Pervasives.html#TYPEref">ref</a> -><br> string array -><br> (<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list -> <a href="Arg.html#TYPEanon_fun">anon_fun</a> -> <a href="Arg.html#TYPEusage_msg">usage_msg</a> -> unit</code></pre><div class="info "> <div class="info-desc"> <p><code class="code"><span class="constructor">Arg</span>.parse_argv ~current args speclist anon_fun usage_msg</code> parses the array <code class="code">args</code> as if it were the command line. It uses and updates the value of <code class="code">~current</code> (if given), or <a href="Arg.html#VALcurrent"><code class="code"><span class="constructor">Arg</span>.current</code></a>. You must set it before calling <code class="code">parse_argv</code>. The initial value of <code class="code">current</code> is the index of the program name (argument 0) in the array. If an error occurs, <code class="code"><span class="constructor">Arg</span>.parse_argv</code> raises <a href="Arg.html#EXCEPTIONBad"><code class="code"><span class="constructor">Arg</span>.<span class="constructor">Bad</span></code></a> with the error message as argument. If option <code class="code">-help</code> or <code class="code">--help</code> is given, <code class="code"><span class="constructor">Arg</span>.parse_argv</code> raises <a href="Arg.html#EXCEPTIONHelp"><code class="code"><span class="constructor">Arg</span>.<span class="constructor">Help</span></code></a> with the help message as argument.</p> </div> </div> <pre><span id="VALparse_argv_dynamic"><span class="keyword">val</span> parse_argv_dynamic</span> : <code class="type">?current:int <a href="Pervasives.html#TYPEref">ref</a> -><br> string array -><br> (<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list <a href="Pervasives.html#TYPEref">ref</a> -><br> <a href="Arg.html#TYPEanon_fun">anon_fun</a> -> string -> unit</code></pre><div class="info "> <div class="info-desc"> <p>Same as <a href="Arg.html#VALparse_argv"><code class="code"><span class="constructor">Arg</span>.parse_argv</code></a>, except that the <code class="code">speclist</code> argument is a reference and may be updated during the parsing. See <a href="Arg.html#VALparse_dynamic"><code class="code"><span class="constructor">Arg</span>.parse_dynamic</code></a>.</p> </div> <ul class="info-attributes"> <li><b>Since</b> 4.01.0</li> </ul> </div> <pre><span id="VALparse_and_expand_argv_dynamic"><span class="keyword">val</span> parse_and_expand_argv_dynamic</span> : <code class="type">int <a href="Pervasives.html#TYPEref">ref</a> -><br> string array <a href="Pervasives.html#TYPEref">ref</a> -><br> (<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list <a href="Pervasives.html#TYPEref">ref</a> -><br> <a href="Arg.html#TYPEanon_fun">anon_fun</a> -> string -> unit</code></pre><div class="info "> <div class="info-desc"> <p>Same as <a href="Arg.html#VALparse_argv_dynamic"><code class="code"><span class="constructor">Arg</span>.parse_argv_dynamic</code></a>, except that the <code class="code">argv</code> argument is a reference and may be updated during the parsing of <code class="code"><span class="constructor">Expand</span></code> arguments. See <a href="Arg.html#VALparse_argv_dynamic"><code class="code"><span class="constructor">Arg</span>.parse_argv_dynamic</code></a>.</p> </div> <ul class="info-attributes"> <li><b>Since</b> 4.05.0</li> </ul> </div> <pre><span id="VALparse_expand"><span class="keyword">val</span> parse_expand</span> : <code class="type">(<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list -> <a href="Arg.html#TYPEanon_fun">anon_fun</a> -> <a href="Arg.html#TYPEusage_msg">usage_msg</a> -> unit</code></pre><div class="info "> <div class="info-desc"> <p>Same as <a href="Arg.html#VALparse"><code class="code"><span class="constructor">Arg</span>.parse</code></a>, except that the <code class="code"><span class="constructor">Expand</span></code> arguments are allowed and the <a href="Arg.html#VALcurrent"><code class="code"><span class="constructor">Arg</span>.current</code></a> reference is not updated.</p> </div> <ul class="info-attributes"> <li><b>Since</b> 4.05.0</li> </ul> </div> <pre><span id="EXCEPTIONHelp"><span class="keyword">exception</span> Help</span> <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info "> <div class="info-desc"> <p>Raised by <code class="code"><span class="constructor">Arg</span>.parse_argv</code> when the user asks for help.</p> </div> </div> <pre><span id="EXCEPTIONBad"><span class="keyword">exception</span> Bad</span> <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info "> <div class="info-desc"> <p>Functions in <code class="code">spec</code> or <code class="code">anon_fun</code> can raise <code class="code"><span class="constructor">Arg</span>.<span class="constructor">Bad</span></code> with an error message to reject invalid arguments. <code class="code"><span class="constructor">Arg</span>.<span class="constructor">Bad</span></code> is also raised by <a href="Arg.html#VALparse_argv"><code class="code"><span class="constructor">Arg</span>.parse_argv</code></a> in case of an error.</p> </div> </div> <pre><span id="VALusage"><span class="keyword">val</span> usage</span> : <code class="type">(<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list -> <a href="Arg.html#TYPEusage_msg">usage_msg</a> -> unit</code></pre><div class="info "> <div class="info-desc"> <p><code class="code"><span class="constructor">Arg</span>.usage speclist usage_msg</code> prints to standard error an error message that includes the list of valid options. This is the same message that <a href="Arg.html#VALparse"><code class="code"><span class="constructor">Arg</span>.parse</code></a> prints in case of error. <code class="code">speclist</code> and <code class="code">usage_msg</code> are the same as for <a href="Arg.html#VALparse"><code class="code"><span class="constructor">Arg</span>.parse</code></a>.</p> </div> </div> <pre><span id="VALusage_string"><span class="keyword">val</span> usage_string</span> : <code class="type">(<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list -> <a href="Arg.html#TYPEusage_msg">usage_msg</a> -> string</code></pre><div class="info "> <div class="info-desc"> <p>Returns the message that would have been printed by <a href="Arg.html#VALusage"><code class="code"><span class="constructor">Arg</span>.usage</code></a>, if provided with the same parameters.</p> </div> </div> <pre><span id="VALalign"><span class="keyword">val</span> align</span> : <code class="type">?limit:int -><br> (<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list -> (<a href="Arg.html#TYPEkey">key</a> * <a href="Arg.html#TYPEspec">spec</a> * <a href="Arg.html#TYPEdoc">doc</a>) list</code></pre><div class="info "> <div class="info-desc"> <p>Align the documentation strings by inserting spaces at the first alignment separator (tab or, if tab is not found, space), according to the length of the keyword. Use a alignment separator as the first character in a doc string if you want to align the whole string. The doc strings corresponding to <code class="code"><span class="constructor">Symbol</span></code> arguments are aligned on the next line.</p> </div> </div> <div class="param_info"><code class="code">limit</code> : options with keyword and message longer than <code class="code">limit</code> will not be used to compute the alignment.</div> <pre><span id="VALcurrent"><span class="keyword">val</span> current</span> : <code class="type">int <a href="Pervasives.html#TYPEref">ref</a></code></pre><div class="info "> <div class="info-desc"> <p>Position (in <a href="Sys.html#VALargv"><code class="code"><span class="constructor">Sys</span>.argv</code></a>) of the argument being processed. You can change this value, e.g. to force <a href="Arg.html#VALparse"><code class="code"><span class="constructor">Arg</span>.parse</code></a> to skip some arguments. <a href="Arg.html#VALparse"><code class="code"><span class="constructor">Arg</span>.parse</code></a> uses the initial value of <a href="Arg.html#VALcurrent"><code class="code"><span class="constructor">Arg</span>.current</code></a> as the index of argument 0 (the program name) and starts parsing arguments at the next element.</p> </div> </div> <pre><span id="VALread_arg"><span class="keyword">val</span> read_arg</span> : <code class="type">string -> string array</code></pre><div class="info "> <div class="info-desc"> <p><code class="code"><span class="constructor">Arg</span>.read_arg file</code> reads newline-terminated command line arguments from file <code class="code">file</code>.</p> </div> <ul class="info-attributes"> <li><b>Since</b> 4.05.0</li> </ul> </div> <pre><span id="VALread_arg0"><span class="keyword">val</span> read_arg0</span> : <code class="type">string -> string array</code></pre><div class="info "> <div class="info-desc"> <p>Identical to <a href="Arg.html#VALread_arg"><code class="code"><span class="constructor">Arg</span>.read_arg</code></a> but assumes null character terminated command line arguments.</p> </div> <ul class="info-attributes"> <li><b>Since</b> 4.05.0</li> </ul> </div> <pre><span id="VALwrite_arg"><span class="keyword">val</span> write_arg</span> : <code class="type">string -> string array -> unit</code></pre><div class="info "> <div class="info-desc"> <p><code class="code"><span class="constructor">Arg</span>.write_arg file args</code> writes the arguments <code class="code">args</code> newline-terminated into the file <code class="code">file</code>. If the any of the arguments in <code class="code">args</code> contains a newline, use <a href="Arg.html#VALwrite_arg0"><code class="code"><span class="constructor">Arg</span>.write_arg0</code></a> instead.</p> </div> <ul class="info-attributes"> <li><b>Since</b> 4.05.0</li> </ul> </div> <pre><span id="VALwrite_arg0"><span class="keyword">val</span> write_arg0</span> : <code class="type">string -> string array -> unit</code></pre><div class="info "> <div class="info-desc"> <p>Identical to <a href="Arg.html#VALwrite_arg"><code class="code"><span class="constructor">Arg</span>.write_arg</code></a> but uses the null character for terminator instead of newline.</p> </div> <ul class="info-attributes"> <li><b>Since</b> 4.05.0</li> </ul> </div> </body></html>