<!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"> <link rel="Start" href="index.html"> <link rel="previous" href="OptParse.Formatter.html"> <link rel="Up" href="OptParse.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 class methods" rel=Appendix href="index_methods.html"> <link title="Index of classes" rel=Appendix href="index_classes.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Base64" rel="Chapter" href="Base64.html"> <link title="BitSet" rel="Chapter" href="BitSet.html"> <link title="Dllist" rel="Chapter" href="Dllist.html"> <link title="DynArray" rel="Chapter" href="DynArray.html"> <link title="Enum" rel="Chapter" href="Enum.html"> <link title="ExtArray" rel="Chapter" href="ExtArray.html"> <link title="ExtHashtbl" rel="Chapter" href="ExtHashtbl.html"> <link title="ExtList" rel="Chapter" href="ExtList.html"> <link title="ExtString" rel="Chapter" href="ExtString.html"> <link title="Global" rel="Chapter" href="Global.html"> <link title="IO" rel="Chapter" href="IO.html"> <link title="OptParse" rel="Chapter" href="OptParse.html"> <link title="Option" rel="Chapter" href="Option.html"> <link title="PMap" rel="Chapter" href="PMap.html"> <link title="RefList" rel="Chapter" href="RefList.html"> <link title="Std" rel="Chapter" href="Std.html"> <link title="UChar" rel="Chapter" href="UChar.html"> <link title="UTF8" rel="Chapter" href="UTF8.html"> <link title="Unzip" rel="Chapter" href="Unzip.html"><link title="Exceptions" rel="Section" href="#6_Exceptions"> <link title="Types" rel="Section" href="#6_Types"> <link title="Option parser creation" rel="Section" href="#6_Optionparsercreation"> <link title="Output and error handling" rel="Section" href="#6_Outputanderrorhandling"> <link title="Option parsing" rel="Section" href="#6_Optionparsing"> <title>OptParse.OptParser</title> </head> <body> <div class="navbar"><a href="OptParse.Formatter.html">Previous</a> <a href="OptParse.html">Up</a> </div> <center><h1>Module <a href="type_OptParse.OptParser.html">OptParse.OptParser</a></h1></center> <br> <pre><span class="keyword">module</span> OptParser: <code class="code">sig</code> <a href="OptParse.OptParser.html">..</a> <code class="code">end</code></pre>This module contains the option parser itself. <p> It provides functions to create, populate and use option parsers to parse command line arguments.<br> <hr width="100%"> <br> <a name="6_Exceptions"></a> <h6>Exceptions</h6><br> <pre><span class="keyword">exception</span> <a name="EXCEPTIONOption_conflict"></a>Option_conflict <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> <code class="code">Option_conflict name</code> is raised by <a href="OptParse.OptParser.html#VALadd"><code class="code">OptParse.OptParser.add</code></a> when two different options are added with identical names. Usually this doesn't need to be caught since this error is usually easily fixed permanently by removing/renaming the conflicting option names.<br> </div> <br> <a name="6_Types"></a> <h6>Types</h6><br> <pre><span class="keyword">type</span> <a name="TYPEt"></a><code class="type"></code>t </pre> <div class="info"> The type of an option parser.<br> </div> <pre><span class="keyword">type</span> <a name="TYPEgroup"></a><code class="type"></code>group </pre> <div class="info"> The type of an option group.<br> </div> <br> <a name="6_Optionparsercreation"></a> <h6>Option parser creation</h6><br> <pre><span class="keyword">val</span> <a name="VALmake"></a>make : <code class="type">?usage:string -><br> ?description:string -><br> ?version:string -><br> ?suppress_usage:bool -><br> ?suppress_help:bool -><br> ?prog:string -><br> ?formatter:<a href="OptParse.Formatter.html#TYPEt">OptParse.Formatter.t</a> -> unit -> <a href="OptParse.OptParser.html#TYPEt">t</a></code></pre><div class="info"> Creates a new option parser with the given options.<br> <b>Returns</b> the new option parser.<br> </div> <div class="param_info"><code class="code">usage</code> : Usage message. The default is a reasonable usage message for most programs. Any occurrence of the substring <code class="code">"%prog"</code> in <code class="code">usage</code> is replaced with the name of the program (see <code class="code">prog</code>).</div> <div class="param_info"><code class="code">version</code> : Version string. If set, a '--version' option is automatically added. When encountered on the command line it causes <code class="code">version</code> to be printed to the standard output and the program to exit.</div> <div class="param_info"><code class="code">suppress_usage</code> : Suppress the usage message if set.</div> <div class="param_info"><code class="code">suppress_help</code> : Suppress the 'help' option which is otherwise added by default.</div> <div class="param_info"><code class="code">prog</code> : Program name. The default is the base name of the executable.</div> <pre><span class="keyword">val</span> <a name="VALadd"></a>add : <code class="type"><a href="OptParse.OptParser.html#TYPEt">t</a> -><br> ?group:<a href="OptParse.OptParser.html#TYPEgroup">group</a> -><br> ?help:string -><br> ?hide:bool -><br> ?short_name:char -><br> ?short_names:char list -><br> ?long_name:string -> ?long_names:string list -> 'a <a href="OptParse.Opt.html#TYPEt">OptParse.Opt.t</a> -> unit</code></pre><div class="info"> Add an option to the option parser.<br> <b>Raises</b> <code>Option_conflict</code> if the short name(s) or long name(s) have alread been used for some other option.<br> </div> <div class="param_info"><code class="code">help</code> : Short help message describing the option (for the usage message).</div> <div class="param_info"><code class="code">hide</code> : If true, hide the option from the usage message. This can be used to implement "secret" options which are not shown, but work just the same as regular options in all other respects.</div> <div class="param_info"><code class="code">short_name</code> : is the name for the short form of the option (e.g. <code class="code">'x'</code> means that the option is invoked with <code class="code">-x</code> on the command line).</div> <div class="param_info"><code class="code">short_names</code> : is a list of names for the short form of the option (see <code class="code">short_name</code>).</div> <div class="param_info"><code class="code">long_name</code> : is the name for the long form of the option (e.g. <code class="code">"xyzzy"</code> means that the option is invoked with <code class="code">--xyzzy</code> on the command line).</div> <div class="param_info"><code class="code">long_names</code> : is a list of names for the long form of the option (see <code class="code">long_name</code>).</div> <pre><span class="keyword">val</span> <a name="VALadd_group"></a>add_group : <code class="type"><a href="OptParse.OptParser.html#TYPEt">t</a> -><br> ?parent:<a href="OptParse.OptParser.html#TYPEgroup">group</a> -><br> ?description:string -> string -> <a href="OptParse.OptParser.html#TYPEgroup">group</a></code></pre><div class="info"> Add a group to the option parser.<br> <b>Returns</b> the new group.<br> </div> <div class="param_info"><code class="code">parent</code> : is the parent group (if any).</div> <div class="param_info"><code class="code">description</code> : is a description of the group.</div> <br> <a name="6_Outputanderrorhandling"></a> <h6>Output and error handling</h6><br> <pre><span class="keyword">val</span> <a name="VALerror"></a>error : <code class="type"><a href="OptParse.OptParser.html#TYPEt">t</a> -><br> ?chn:Pervasives.out_channel -> ?status:int -> string -> unit</code></pre><div class="info"> Display an error message and exit the program. The error message is printed to the channel <code class="code">chn</code> (default is <code class="code">Pervasives.stderr</code>) and the program exits with exit status <code class="code">status</code> (default is 1).<br> </div> <pre><span class="keyword">val</span> <a name="VALusage"></a>usage : <code class="type"><a href="OptParse.OptParser.html#TYPEt">t</a> -> ?chn:Pervasives.out_channel -> unit -> unit</code></pre><div class="info"> Display the usage message to the channel <code class="code">chn</code> (default is <code class="code">Pervasives.stdout</code>) and return.<br> </div> <br> <a name="6_Optionparsing"></a> <h6>Option parsing</h6><br> <pre><span class="keyword">val</span> <a name="VALparse"></a>parse : <code class="type"><a href="OptParse.OptParser.html#TYPEt">t</a> -><br> ?first:int -> ?last:int -> string array -> string list</code></pre><div class="info"> Parse arguments as if the arguments <code class="code">args.(first)</code>, <code class="code">args.(first+1)</code>, ..., <code class="code">args.(last)</code> had been given on the command line. By default <code class="code">first</code> is 0 and <code class="code">last</code> is the index of the last element of the array.<br> </div> <pre><span class="keyword">val</span> <a name="VALparse_argv"></a>parse_argv : <code class="type"><a href="OptParse.OptParser.html#TYPEt">t</a> -> string list</code></pre><div class="info"> Parse all the arguments in <code class="code">Sys.argv</code>.<br> </div> </body></html>