moonpool/dev/ocaml/Stdlib/Arg/index.html
2023-08-28 17:11:38 +00:00

38 lines
No EOL
26 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 (ocaml.Stdlib.Arg)</title><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><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">ocaml</a> &#x00BB; <a href="../index.html">Stdlib</a> &#x00BB; Arg</nav><header class="odoc-preamble"><h1>Module <code><span>Stdlib.Arg</span></code></h1><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. For example:</p><pre class="language-ocaml"><code>let usage_msg = &quot;append [-verbose] &lt;file1&gt; [&lt;file2&gt;] ... -o &lt;output&gt;&quot;
let verbose = ref false
let input_files = ref []
let output_file = ref &quot;&quot;
let anon_fun filename =
input_files := filename::!input_files
let speclist =
[(&quot;-verbose&quot;, Arg.Set verbose, &quot;Output debug information&quot;);
(&quot;-o&quot;, Arg.Set_string output_file, &quot;Set output file name&quot;)]
let () =
Arg.parse speclist anon_fun usage_msg;
(* Main functionality here *)</code></pre><p>Syntax of command lines: A keyword is a character string starting with a <code>-</code>. An option is a keyword alone or followed by an argument. The types of keywords are: <code>Unit</code>, <code>Bool</code>, <code>Set</code>, <code>Clear</code>, <code>String</code>, <code>Set_string</code>, <code>Int</code>, <code>Set_int</code>, <code>Float</code>, <code>Set_float</code>, <code>Tuple</code>, <code>Symbol</code>, <code>Rest</code>, <code>Rest_all</code> and <code>Expand</code>.</p><p><code>Unit</code>, <code>Set</code> and <code>Clear</code> keywords take no argument.</p><p>A <code>Rest</code> or <code>Rest_all</code> keyword takes the remainder of the command line as arguments. (More explanations below.)</p><p>Every other keyword takes the following word on the command line as argument. For compatibility with GNU getopt_long, <code>keyword=arg</code> is also allowed. Arguments not preceded by a keyword are called anonymous arguments.</p><p>Examples (<code>cmd</code> is assumed to be the command name):</p><ul><li><code>cmd -flag </code>(a unit option)</li><li><code>cmd -int 1 </code>(an int option with argument <code>1</code>)</li><li><code>cmd -string foobar </code>(a string option with argument <code>&quot;foobar&quot;</code>)</li><li><code>cmd -float 12.34 </code>(a float option with argument <code>12.34</code>)</li><li><code>cmd a b c </code>(three anonymous arguments: <code>&quot;a&quot;</code>, <code>&quot;b&quot;</code>, and <code>&quot;c&quot;</code>)</li><li><code>cmd a b -- c d </code>(two anonymous arguments and a rest option with two arguments)</li></ul><p><code>Rest</code> takes a function that is called repeatedly for each remaining command line argument. <code>Rest_all</code> takes a function that is called once, with the list of all remaining arguments.</p><p>Note that if no arguments follow a <code>Rest</code> keyword then the function is not called at all whereas the function for a <code>Rest_all</code> keyword is called with an empty list.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-spec"><a href="#type-spec" class="anchor"></a><code><span><span class="keyword">type</span> spec</span><span> = </span></code><ol><li id="type-spec.Unit" class="def variant constructor anchored"><a href="#type-spec.Unit" class="anchor"></a><code><span>| </span><span><span class="constructor">Unit</span> <span class="keyword">of</span> <span>unit <span class="arrow">&#45;&gt;</span></span> unit</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Call the function with unit argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Bool" class="def variant constructor anchored"><a href="#type-spec.Bool" class="anchor"></a><code><span>| </span><span><span class="constructor">Bool</span> <span class="keyword">of</span> <span>bool <span class="arrow">&#45;&gt;</span></span> unit</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Call the function with a bool argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Set" class="def variant constructor anchored"><a href="#type-spec.Set" class="anchor"></a><code><span>| </span><span><span class="constructor">Set</span> <span class="keyword">of</span> <span>bool <a href="../index.html#type-ref">ref</a></span></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Set the reference to true</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Clear" class="def variant constructor anchored"><a href="#type-spec.Clear" class="anchor"></a><code><span>| </span><span><span class="constructor">Clear</span> <span class="keyword">of</span> <span>bool <a href="../index.html#type-ref">ref</a></span></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Set the reference to false</p><span class="comment-delim">*)</span></div></li><li id="type-spec.String" class="def variant constructor anchored"><a href="#type-spec.String" class="anchor"></a><code><span>| </span><span><span class="constructor">String</span> <span class="keyword">of</span> <span>string <span class="arrow">&#45;&gt;</span></span> unit</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Call the function with a string argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Set_string" class="def variant constructor anchored"><a href="#type-spec.Set_string" class="anchor"></a><code><span>| </span><span><span class="constructor">Set_string</span> <span class="keyword">of</span> <span>string <a href="../index.html#type-ref">ref</a></span></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Set the reference to the string argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Int" class="def variant constructor anchored"><a href="#type-spec.Int" class="anchor"></a><code><span>| </span><span><span class="constructor">Int</span> <span class="keyword">of</span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Call the function with an int argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Set_int" class="def variant constructor anchored"><a href="#type-spec.Set_int" class="anchor"></a><code><span>| </span><span><span class="constructor">Set_int</span> <span class="keyword">of</span> <span>int <a href="../index.html#type-ref">ref</a></span></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Set the reference to the int argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Float" class="def variant constructor anchored"><a href="#type-spec.Float" class="anchor"></a><code><span>| </span><span><span class="constructor">Float</span> <span class="keyword">of</span> <span>float <span class="arrow">&#45;&gt;</span></span> unit</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Call the function with a float argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Set_float" class="def variant constructor anchored"><a href="#type-spec.Set_float" class="anchor"></a><code><span>| </span><span><span class="constructor">Set_float</span> <span class="keyword">of</span> <span>float <a href="../index.html#type-ref">ref</a></span></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Set the reference to the float argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Tuple" class="def variant constructor anchored"><a href="#type-spec.Tuple" class="anchor"></a><code><span>| </span><span><span class="constructor">Tuple</span> <span class="keyword">of</span> <span><a href="#type-spec">spec</a> list</span></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Take several arguments according to the spec list</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Symbol" class="def variant constructor anchored"><a href="#type-spec.Symbol" class="anchor"></a><code><span>| </span><span><span class="constructor">Symbol</span> <span class="keyword">of</span> <span>string list</span> * <span>string <span class="arrow">&#45;&gt;</span></span> unit</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Take one of the symbols as argument and call the function with the symbol</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Rest" class="def variant constructor anchored"><a href="#type-spec.Rest" class="anchor"></a><code><span>| </span><span><span class="constructor">Rest</span> <span class="keyword">of</span> <span>string <span class="arrow">&#45;&gt;</span></span> unit</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Stop interpreting keywords and call the function with each remaining argument</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Rest_all" class="def variant constructor anchored"><a href="#type-spec.Rest_all" class="anchor"></a><code><span>| </span><span><span class="constructor">Rest_all</span> <span class="keyword">of</span> <span><span>string list</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Stop interpreting keywords and call the function with all remaining arguments</p><span class="comment-delim">*)</span></div></li><li id="type-spec.Expand" class="def variant constructor anchored"><a href="#type-spec.Expand" class="anchor"></a><code><span>| </span><span><span class="constructor">Expand</span> <span class="keyword">of</span> <span>string <span class="arrow">&#45;&gt;</span></span> <span>string array</span></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>If the remaining arguments to process are of the form <code>[&quot;-foo&quot;; &quot;arg&quot;] @ rest</code> where &quot;foo&quot; is registered as <code>Expand f</code>, then the arguments <code>f &quot;arg&quot; @ rest</code> are processed. Only allowed in <code>parse_and_expand_argv_dynamic</code>.</p><span class="comment-delim">*)</span></div></li></ol></div><div class="spec-doc"><p>The concrete type describing the behavior associated with a keyword.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-key"><a href="#type-key" class="anchor"></a><code><span><span class="keyword">type</span> key</span><span> = string</span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-doc"><a href="#type-doc" class="anchor"></a><code><span><span class="keyword">type</span> doc</span><span> = string</span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-usage_msg"><a href="#type-usage_msg" class="anchor"></a><code><span><span class="keyword">type</span> usage_msg</span><span> = string</span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-anon_fun"><a href="#type-anon_fun" class="anchor"></a><code><span><span class="keyword">type</span> anon_fun</span><span> = <span>string <span class="arrow">&#45;&gt;</span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parse"><a href="#val-parse" class="anchor"></a><code><span><span class="keyword">val</span> parse : <span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-anon_fun">anon_fun</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-usage_msg">usage_msg</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>Arg.parse speclist anon_fun usage_msg</code> parses the command line. <code>speclist</code> is a list of triples <code>(key, spec, doc)</code>. <code>key</code> is the option keyword, it must start with a <code>'-'</code> character. <code>spec</code> gives the option type and the function to call when this option is found on the command line. <code>doc</code> is a one-line description of this option. <code>anon_fun</code> is called on anonymous arguments. The functions in <code>spec</code> and <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>Arg.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>usage_msg</code></li><li>The list of options, each followed by the corresponding <code>doc</code> string. Beware: options that have an empty <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>-</code>, include for example <code>(&quot;-&quot;, String anon_fun, doc)</code> in <code>speclist</code>.</p><p>By default, <code>parse</code> recognizes two unit options, <code>-help</code> and <code>--help</code>, which will print to standard output <code>usage_msg</code> and the list of options, and exit the program. You can override this behaviour by specifying your own <code>-help</code> and <code>--help</code> options in <code>speclist</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parse_dynamic"><a href="#val-parse_dynamic" class="anchor"></a><code><span><span class="keyword">val</span> parse_dynamic :
<span><span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <a href="../index.html#type-ref">ref</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-anon_fun">anon_fun</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-usage_msg">usage_msg</a> <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-parse"><code>Arg.parse</code></a>, except that the <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>options</code> where the list of options depends on the value of the subcommand argument.</li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.01.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parse_argv"><a href="#val-parse_argv" class="anchor"></a><code><span><span class="keyword">val</span> parse_argv :
<span>?current:<span>int <a href="../index.html#type-ref">ref</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span>string array</span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-anon_fun">anon_fun</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-usage_msg">usage_msg</a> <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div><div class="spec-doc"><p><code>Arg.parse_argv ~current args speclist anon_fun usage_msg</code> parses the array <code>args</code> as if it were the command line. It uses and updates the value of <code>~current</code> (if given), or <a href="#val-current"><code>Arg.current</code></a>. You must set it before calling <code>parse_argv</code>. The initial value of <code>current</code> is the index of the program name (argument 0) in the array. If an error occurs, <code>Arg.parse_argv</code> raises <a href="#exception-Bad"><code>Arg.Bad</code></a> with the error message as argument. If option <code>-help</code> or <code>--help</code> is given, <code>Arg.parse_argv</code> raises <a href="#exception-Help"><code>Arg.Help</code></a> with the help message as argument.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parse_argv_dynamic"><a href="#val-parse_argv_dynamic" class="anchor"></a><code><span><span class="keyword">val</span> parse_argv_dynamic :
<span>?current:<span>int <a href="../index.html#type-ref">ref</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span>string array</span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <a href="../index.html#type-ref">ref</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-anon_fun">anon_fun</a> <span class="arrow">&#45;&gt;</span></span>
<span>string <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-parse_argv"><code>Arg.parse_argv</code></a>, except that the <code>speclist</code> argument is a reference and may be updated during the parsing. See <a href="#val-parse_dynamic"><code>Arg.parse_dynamic</code></a>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.01.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parse_and_expand_argv_dynamic"><a href="#val-parse_and_expand_argv_dynamic" class="anchor"></a><code><span><span class="keyword">val</span> parse_and_expand_argv_dynamic :
<span><span>int <a href="../index.html#type-ref">ref</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>string array</span> <a href="../index.html#type-ref">ref</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <a href="../index.html#type-ref">ref</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-anon_fun">anon_fun</a> <span class="arrow">&#45;&gt;</span></span>
<span>string <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-parse_argv_dynamic"><code>Arg.parse_argv_dynamic</code></a>, except that the <code>argv</code> argument is a reference and may be updated during the parsing of <code>Expand</code> arguments. See <a href="#val-parse_argv_dynamic"><code>Arg.parse_argv_dynamic</code></a>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parse_expand"><a href="#val-parse_expand" class="anchor"></a><code><span><span class="keyword">val</span> parse_expand : <span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-anon_fun">anon_fun</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-usage_msg">usage_msg</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-parse"><code>Arg.parse</code></a>, except that the <code>Expand</code> arguments are allowed and the <a href="#val-current"><code>current</code></a> reference is not updated.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05.0</li></ul></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Help"><a href="#exception-Help" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Help</span> <span class="keyword">of</span> string</span></code></div><div class="spec-doc"><p>Raised by <code>Arg.parse_argv</code> when the user asks for help.</p></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Bad"><a href="#exception-Bad" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Bad</span> <span class="keyword">of</span> string</span></code></div><div class="spec-doc"><p>Functions in <code>spec</code> or <code>anon_fun</code> can raise <code>Arg.Bad</code> with an error message to reject invalid arguments. <code>Arg.Bad</code> is also raised by <a href="#val-parse_argv"><code>Arg.parse_argv</code></a> in case of an error.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-usage"><a href="#val-usage" class="anchor"></a><code><span><span class="keyword">val</span> usage : <span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-usage_msg">usage_msg</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>Arg.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="#val-parse"><code>Arg.parse</code></a> prints in case of error. <code>speclist</code> and <code>usage_msg</code> are the same as for <a href="#val-parse"><code>Arg.parse</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-usage_string"><a href="#val-usage_string" class="anchor"></a><code><span><span class="keyword">val</span> usage_string : <span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-usage_msg">usage_msg</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Returns the message that would have been printed by <a href="#val-usage"><code>Arg.usage</code></a>, if provided with the same parameters.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-align"><a href="#val-align" class="anchor"></a><code><span><span class="keyword">val</span> align : <span>?limit:int <span class="arrow">&#45;&gt;</span></span> <span><span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span> <span class="arrow">&#45;&gt;</span></span> <span><span>(<a href="#type-key">key</a> * <a href="#type-spec">spec</a> * <a href="#type-doc">doc</a>)</span> list</span></span></code></div><div class="spec-doc"><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>Symbol</code> arguments are aligned on the next line.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">limit</span> <p>options with keyword and message longer than <code>limit</code> will not be used to compute the alignment.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-current"><a href="#val-current" class="anchor"></a><code><span><span class="keyword">val</span> current : <span>int <a href="../index.html#type-ref">ref</a></span></span></code></div><div class="spec-doc"><p>Position (in <a href="../Sys/index.html#val-argv"><code>Sys.argv</code></a>) of the argument being processed. You can change this value, e.g. to force <a href="#val-parse"><code>Arg.parse</code></a> to skip some arguments. <a href="#val-parse"><code>Arg.parse</code></a> uses the initial value of <a href="#val-current"><code>Arg.current</code></a> as the index of argument 0 (the program name) and starts parsing arguments at the next element.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_arg"><a href="#val-read_arg" class="anchor"></a><code><span><span class="keyword">val</span> read_arg : <span>string <span class="arrow">&#45;&gt;</span></span> <span>string array</span></span></code></div><div class="spec-doc"><p><code>Arg.read_arg file</code> reads newline-terminated command line arguments from file <code>file</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_arg0"><a href="#val-read_arg0" class="anchor"></a><code><span><span class="keyword">val</span> read_arg0 : <span>string <span class="arrow">&#45;&gt;</span></span> <span>string array</span></span></code></div><div class="spec-doc"><p>Identical to <a href="#val-read_arg"><code>Arg.read_arg</code></a> but assumes null character terminated command line arguments.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_arg"><a href="#val-write_arg" class="anchor"></a><code><span><span class="keyword">val</span> write_arg : <span>string <span class="arrow">&#45;&gt;</span></span> <span><span>string array</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>Arg.write_arg file args</code> writes the arguments <code>args</code> newline-terminated into the file <code>file</code>. If the any of the arguments in <code>args</code> contains a newline, use <a href="#val-write_arg0"><code>Arg.write_arg0</code></a> instead.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_arg0"><a href="#val-write_arg0" class="anchor"></a><code><span><span class="keyword">val</span> write_arg0 : <span>string <span class="arrow">&#45;&gt;</span></span> <span><span>string array</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Identical to <a href="#val-write_arg"><code>Arg.write_arg</code></a> but uses the null character for terminator instead of newline.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05.0</li></ul></div></div></div></body></html>