Moved to consuming builder pattern. Cleaned up borrows and fields.

This commit is contained in:
Kevin K 2015-03-03 22:45:11 -05:00
parent d084a40f4a
commit ea3de882ea
10 changed files with 152 additions and 104 deletions

2
Cargo.lock generated
View file

@ -1,4 +1,4 @@
[root]
name = "clap"
version = "0.3.6"
version = "0.3.7"

View file

@ -1,7 +1,7 @@
[package]
name = "clap"
version = "0.3.6"
version = "0.3.7"
authors = ["Kevin K. <kbknapp@gmail.com>"]
exclude = ["docs/*"]
description = "A Command Line Argument Parser written in Rust"

View file

@ -43,7 +43,7 @@
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Crate <a class='mod' href=''>clap</a><wbr></span><span class='out-of-band'><a href='stability.html'>[stability]</a> <span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-0' href='../src/clap/lib.rs.html#1-116'>[src]</a></span></h1>
</span><a id='src-0' href='../src/clap/lib.rs.html#1-136'>[src]</a></span></h1>
<div class='docblock'><p>A simply library for parsing command line arguments when writing
command line and console applications.</p>

View file

@ -83,28 +83,28 @@ to the user when they print version or help and usage information.</p>
<pre id='rust-example-rendered' class='rust '>
<span class='kw'>let</span> <span class='ident'>prog</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;myprog&quot;</span>)
</pre>
</div><h4 id='method.author' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.author' class='fnname'>author</a>(&amp;mut self, a: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
</div><h4 id='method.author' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.author' class='fnname'>author</a>(self, a: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Sets a string of author(s)</p>
<p>Example:</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>author</span>(<span class='string'>&quot;Kevin &lt;kbknapp@gmail.com&gt;&quot;</span>)
</pre>
</div><h4 id='method.about' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.about' class='fnname'>about</a>(&amp;mut self, a: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
</div><h4 id='method.about' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.about' class='fnname'>about</a>(self, a: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Sets a string briefly describing what the program does</p>
<p>Example:</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>about</span>(<span class='string'>&quot;Does really amazing things to great people&quot;</span>)
</pre>
</div><h4 id='method.version' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.version' class='fnname'>version</a>(&amp;mut self, v: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
</div><h4 id='method.version' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.version' class='fnname'>version</a>(self, v: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Sets a string of the version number</p>
<p>Example:</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>version</span>(<span class='string'>&quot;v0.1.24&quot;</span>)
</pre>
</div><h4 id='method.arg' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.arg' class='fnname'>arg</a>(&amp;mut self, a: &amp;<a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
</div><h4 id='method.arg' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.arg' class='fnname'>arg</a>(self, a: <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Adds an argument to the list of valid possibilties</p>
<p>Example:</p>
@ -114,7 +114,7 @@ to the user when they print version or help and usage information.</p>
<span class='comment'>// Additional argument configuration goes here...</span>
)
</pre>
</div><h4 id='method.args' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.args' class='fnname'>args</a>(&amp;mut self, args: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;<a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>&gt;) -&gt; &amp;mut <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
</div><h4 id='method.args' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.args' class='fnname'>args</a>(self, args: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>&gt;) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Adds arguments to the list of valid possibilties</p>
<p>Example:</p>
@ -122,7 +122,7 @@ to the user when they print version or help and usage information.</p>
.<span class='ident'>args</span>( <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;c&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;debug&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;d&quot;</span>)])
</pre>
</div><h4 id='method.get_matches' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.get_matches' class='fnname'>get_matches</a>(&amp;mut self) -&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a></code></h4>
</div><h4 id='method.get_matches' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.get_matches' class='fnname'>get_matches</a>(self) -&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a></code></h4>
</div></section>
<section id='search' class="content hidden"></section>

View file

@ -43,7 +43,7 @@
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>Arg</a><wbr></span><span class='out-of-band'><span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-4414' href='../src/clap/arg.rs.html#21-53'>[src]</a></span></h1>
</span><a id='src-4358' href='../src/clap/arg.rs.html#21-53'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Arg {
pub name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
pub short: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a href='http://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>&gt;,
@ -105,7 +105,7 @@ be displayed when the user prints the usage/help information of the program.</p>
<pre id='rust-example-rendered' class='rust '>
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;conifg&quot;</span>)
</pre>
</div><h4 id='method.short' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.short' class='fnname'>short</a>(&amp;mut self, s: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.short' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.short' class='fnname'>short</a>(self, s: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets the short version of the argument without the preceding <code>-</code>.</p>
<p>By default <code>clap</code> automatically assigns <code>v</code> and <code>h</code> to display version and help information
@ -119,7 +119,7 @@ Example:</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>short</span>(<span class='string'>&quot;c&quot;</span>)
</pre>
</div><h4 id='method.long' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.long' class='fnname'>long</a>(&amp;mut self, l: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.long' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.long' class='fnname'>long</a>(self, l: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets the long version of the argument without the preceding <code>--</code>.</p>
<p>By default <code>clap</code> automatically assigns <code>version</code> and <code>help</code> to display version and help information
@ -134,7 +134,7 @@ when the user mistakenly sets the short to <code>--out</code> or the like.</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>long</span>(<span class='string'>&quot;config&quot;</span>)
</pre>
</div><h4 id='method.help' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.help' class='fnname'>help</a>(&amp;mut self, h: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.help' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.help' class='fnname'>help</a>(self, h: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets the help text of the argument that will be displayed to the user
when they print the usage/help information. </p>
@ -142,7 +142,7 @@ when they print the usage/help information. </p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>help</span>(<span class='string'>&quot;The config file used by the myprog&quot;</span>)
</pre>
</div><h4 id='method.required' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.required' class='fnname'>required</a>(&amp;mut self, r: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.required' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.required' class='fnname'>required</a>(self, r: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets whether or not the argument is required by default. Required by
default means it is required, when no other mutually exlusive rules have
been evaluated. Mutually exclusive rules take precedence over being required
@ -156,7 +156,7 @@ when they print the usage/help information. </p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>required</span>(<span class='boolval'>true</span>)
</pre>
</div><h4 id='method.mutually_excludes' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.mutually_excludes' class='fnname'>mutually_excludes</a>(&amp;mut self, name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.mutually_excludes' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.mutually_excludes' class='fnname'>mutually_excludes</a>(self, name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets a mutually exclusive argument by name. I.e. when using this argument,
the following argument can&#39;t be present.</p>
@ -168,7 +168,7 @@ arguments, they do not need to be set for each.</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>mutually_excludes</span>(<span class='string'>&quot;debug&quot;</span>)
</pre>
</div><h4 id='method.mutually_excludes_all' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.mutually_excludes_all' class='fnname'>mutually_excludes_all</a>(&amp;mut self, names: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.mutually_excludes_all' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.mutually_excludes_all' class='fnname'>mutually_excludes_all</a>(self, names: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets a mutually exclusive arguments by names. I.e. when using this argument,
the following argument can&#39;t be present.</p>
@ -181,7 +181,7 @@ arguments, they do not need to be set for each.</p>
.<span class='ident'>mutually_excludes_all</span>(
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>&quot;debug&quot;</span>, <span class='string'>&quot;input&quot;</span>])
</pre>
</div><h4 id='method.requires' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.requires' class='fnname'>requires</a>(&amp;mut self, name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.requires' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.requires' class='fnname'>requires</a>(self, name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets an argument by name that is required when this one is presnet I.e. when
using this argument, the following argument <em>must</em> be present.</p>
@ -191,7 +191,7 @@ using this argument, the following argument <em>must</em> be present.</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>requires</span>(<span class='string'>&quot;debug&quot;</span>)
</pre>
</div><h4 id='method.requires_all' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.requires_all' class='fnname'>requires_all</a>(&amp;mut self, names: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.requires_all' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.requires_all' class='fnname'>requires_all</a>(self, names: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets arguments by names that are required when this one is presnet I.e. when
using this argument, the following arguments <em>must</em> be present.</p>
@ -203,7 +203,7 @@ using this argument, the following argument <em>must</em> be present.</p>
.<span class='ident'>requires_all</span>(
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>&quot;debug&quot;</span>, <span class='string'>&quot;input&quot;</span>])
</pre>
</div><h4 id='method.takes_value' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.takes_value' class='fnname'>takes_value</a>(&amp;mut self, tv: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.takes_value' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.takes_value' class='fnname'>takes_value</a>(self, tv: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Specifies that the argument takes an additional value at run time.</p>
<p><strong>NOTE:</strong> When setting this to <code>true</code> the <code>name</code> of the argument
@ -213,7 +213,7 @@ will be used when printing the help/usage information to the user. </p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>takes_value</span>(<span class='boolval'>true</span>)
</pre>
</div><h4 id='method.index' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.index' class='fnname'>index</a>(&amp;mut self, idx: <a href='http://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.index' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.index' class='fnname'>index</a>(self, idx: <a href='http://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Specifies the index of a positional argument starting at 1.</p>
<p><strong>NOTE:</strong> When setting this, any <code>short</code> or <code>long</code> values you set
@ -225,7 +225,7 @@ to the user. </p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>index</span>(<span class='number'>1</span>)
</pre>
</div><h4 id='method.multiple' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.multiple' class='fnname'>multiple</a>(&amp;mut self, multi: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; &amp;mut <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
</div><h4 id='method.multiple' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.multiple' class='fnname'>multiple</a>(self, multi: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Specifies if the flag may appear more than once such as for multiple debugging
levels (as an example). <code>-ddd</code> for three levels of debugging, or <code>-d -d -d</code>.
When this is set to <code>true</code> you recieve the number of occurances the user supplied

View file

@ -43,7 +43,7 @@
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>ArgMatches</a><wbr></span><span class='out-of-band'><span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-4244' href='../src/clap/argmatches.rs.html#49-59'>[src]</a></span></h1>
</span><a id='src-4188' href='../src/clap/argmatches.rs.html#49-59'>[src]</a></span></h1>
<pre class='rust struct'>pub struct ArgMatches {
pub name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
pub flags: <a class='struct' href='http://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html' title='std::collections::hash::map::HashMap'>HashMap</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, FlagArg&gt;,

View file

@ -757,6 +757,10 @@
<span id="715">715</span>
<span id="716">716</span>
<span id="717">717</span>
<span id="718">718</span>
<span id="719">719</span>
<span id="720">720</span>
<span id="721">721</span>
</pre><pre class='rust '>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libc</span>;
@ -806,7 +810,7 @@
<span class='ident'>flags</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>FlagArg</span><span class='op'>&gt;</span>,
<span class='ident'>opts</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>OptArg</span><span class='op'>&gt;</span>,
<span class='ident'>positionals_idx</span>: <span class='ident'>BTreeMap</span><span class='op'>&lt;</span><span class='ident'>u8</span>, <span class='ident'>PosArg</span><span class='op'>&gt;</span>,
<span class='ident'>positionals_name</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>PosArg</span><span class='op'>&gt;</span>,
<span class='comment'>// positionals_name: HashMap&lt;&amp;&#39;static str, PosArg&gt;,</span>
<span class='ident'>needs_long_help</span>: <span class='ident'>bool</span>,
<span class='ident'>needs_long_version</span>: <span class='ident'>bool</span>,
<span class='ident'>needs_short_help</span>: <span class='ident'>bool</span>,
@ -838,7 +842,7 @@
<span class='ident'>flags</span>: <span class='ident'>HashMap</span>::<span class='ident'>new</span>(),
<span class='ident'>opts</span>: <span class='ident'>HashMap</span>::<span class='ident'>new</span>(),
<span class='ident'>positionals_idx</span>: <span class='ident'>BTreeMap</span>::<span class='ident'>new</span>(),
<span class='ident'>positionals_name</span>: <span class='ident'>HashMap</span>::<span class='ident'>new</span>(),
<span class='comment'>// positionals_name: HashMap::new(),</span>
<span class='ident'>needs_long_version</span>: <span class='boolval'>true</span>,
<span class='ident'>needs_long_help</span>: <span class='boolval'>true</span>,
<span class='ident'>needs_short_help</span>: <span class='boolval'>true</span>,
@ -861,7 +865,7 @@
<span class='doccomment'>/// .author(&quot;Kevin &lt;kbknapp@gmail.com&gt;&quot;)</span>
<span class='doccomment'>/// # .get_matches();</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>author</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>App</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>author</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>App</span> {
<span class='self'>self</span>.<span class='ident'>author</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>a</span>);
<span class='self'>self</span>
}
@ -876,7 +880,7 @@
<span class='doccomment'>/// .about(&quot;Does really amazing things to great people&quot;)</span>
<span class='doccomment'>/// # .get_matches();</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>about</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>App</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>about</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>App</span> {
<span class='self'>self</span>.<span class='ident'>about</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>a</span>);
<span class='self'>self</span>
}
@ -891,7 +895,7 @@
<span class='doccomment'>/// .version(&quot;v0.1.24&quot;)</span>
<span class='doccomment'>/// # .get_matches();</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>version</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>v</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>)<span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>App</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>version</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>v</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>)<span class='op'>-&gt;</span> <span class='ident'>App</span> {
<span class='self'>self</span>.<span class='ident'>version</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>v</span>);
<span class='self'>self</span>
}
@ -909,7 +913,7 @@
<span class='doccomment'>/// )</span>
<span class='doccomment'>/// # .get_matches();</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>arg</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&amp;</span><span class='ident'>Arg</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>App</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>arg</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>a</span>: <span class='ident'>Arg</span>) <span class='op'>-&gt;</span> <span class='ident'>App</span> {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>arg_list</span>.<span class='ident'>contains</span>(<span class='ident'>a</span>.<span class='ident'>name</span>) {
<span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument name must be unique, \&quot;{}\&quot; is already in use&quot;</span>, <span class='ident'>a</span>.<span class='ident'>name</span>);
} <span class='kw'>else</span> {
@ -933,21 +937,21 @@
<span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>insert</span>(<span class='ident'>a</span>.<span class='ident'>name</span>);
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>i</span>) <span class='op'>=</span> <span class='ident'>a</span>.<span class='ident'>index</span> {
<span class='self'>self</span>.<span class='ident'>positionals_name</span>.<span class='ident'>insert</span>(<span class='ident'>a</span>.<span class='ident'>name</span>, <span class='ident'>PosArg</span> {
<span class='ident'>name</span>: <span class='ident'>a</span>.<span class='ident'>name</span>,
<span class='ident'>index</span>: <span class='ident'>i</span>,
<span class='ident'>required</span>: <span class='ident'>a</span>.<span class='ident'>required</span>,
<span class='ident'>help</span>: <span class='ident'>a</span>.<span class='ident'>help</span>,
<span class='ident'>blacklist</span>: <span class='ident'>a</span>.<span class='ident'>blacklist</span>.<span class='ident'>clone</span>(),
<span class='ident'>requires</span>: <span class='ident'>a</span>.<span class='ident'>requires</span>.<span class='ident'>clone</span>(),
<span class='ident'>value</span>: <span class='prelude-val'>None</span>
});
<span class='comment'>// self.positionals_name.insert(a.name, PosArg {</span>
<span class='comment'>// name: a.name,</span>
<span class='comment'>// index: i,</span>
<span class='comment'>// required: a.required,</span>
<span class='comment'>// help: a.help,</span>
<span class='comment'>// blacklist: a.blacklist,</span>
<span class='comment'>// requires: a.requires,</span>
<span class='comment'>// value: None</span>
<span class='comment'>// });</span>
<span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>insert</span>(<span class='ident'>i</span>, <span class='ident'>PosArg</span> {
<span class='ident'>name</span>: <span class='ident'>a</span>.<span class='ident'>name</span>,
<span class='ident'>index</span>: <span class='ident'>i</span>,
<span class='ident'>required</span>: <span class='ident'>a</span>.<span class='ident'>required</span>,
<span class='ident'>blacklist</span>: <span class='ident'>a</span>.<span class='ident'>blacklist</span>.<span class='ident'>clone</span>(),
<span class='ident'>requires</span>: <span class='ident'>a</span>.<span class='ident'>requires</span>.<span class='ident'>clone</span>(),
<span class='ident'>blacklist</span>: <span class='ident'>a</span>.<span class='ident'>blacklist</span>,
<span class='ident'>requires</span>: <span class='ident'>a</span>.<span class='ident'>requires</span>,
<span class='ident'>help</span>: <span class='ident'>a</span>.<span class='ident'>help</span>,
<span class='ident'>value</span>: <span class='prelude-val'>None</span>
});
@ -959,9 +963,9 @@
<span class='ident'>name</span>: <span class='ident'>a</span>.<span class='ident'>name</span>,
<span class='ident'>short</span>: <span class='ident'>a</span>.<span class='ident'>short</span>,
<span class='ident'>long</span>: <span class='ident'>a</span>.<span class='ident'>long</span>,
<span class='ident'>blacklist</span>: <span class='ident'>a</span>.<span class='ident'>blacklist</span>.<span class='ident'>clone</span>(),
<span class='ident'>blacklist</span>: <span class='ident'>a</span>.<span class='ident'>blacklist</span>,
<span class='ident'>help</span>: <span class='ident'>a</span>.<span class='ident'>help</span>,
<span class='ident'>requires</span>: <span class='ident'>a</span>.<span class='ident'>requires</span>.<span class='ident'>clone</span>(),
<span class='ident'>requires</span>: <span class='ident'>a</span>.<span class='ident'>requires</span>,
<span class='ident'>required</span>: <span class='ident'>a</span>.<span class='ident'>required</span>,
<span class='ident'>value</span>: <span class='prelude-val'>None</span>
});
@ -992,9 +996,9 @@
<span class='ident'>short</span>: <span class='ident'>a</span>.<span class='ident'>short</span>,
<span class='ident'>long</span>: <span class='ident'>a</span>.<span class='ident'>long</span>,
<span class='ident'>help</span>: <span class='ident'>a</span>.<span class='ident'>help</span>,
<span class='ident'>blacklist</span>: <span class='ident'>a</span>.<span class='ident'>blacklist</span>.<span class='ident'>clone</span>(),
<span class='ident'>blacklist</span>: <span class='ident'>a</span>.<span class='ident'>blacklist</span>,
<span class='ident'>multiple</span>: <span class='ident'>a</span>.<span class='ident'>multiple</span>,
<span class='ident'>requires</span>: <span class='ident'>a</span>.<span class='ident'>requires</span>.<span class='ident'>clone</span>(),
<span class='ident'>requires</span>: <span class='ident'>a</span>.<span class='ident'>requires</span>,
<span class='ident'>occurrences</span>: <span class='number'>1</span>
});
}
@ -1012,9 +1016,9 @@
<span class='doccomment'>/// Arg::new(&quot;debug&quot;).short(&quot;d&quot;)])</span>
<span class='doccomment'>/// # .get_matches();</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>args</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>args</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>Arg</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>App</span> {
<span class='kw'>for</span> <span class='ident'>arg</span> <span class='kw'>in</span> <span class='ident'>args</span>.<span class='ident'>iter</span>() {
<span class='self'>self</span>.<span class='ident'>arg</span>(<span class='ident'>arg</span>);
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>args</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>args</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>Arg</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='ident'>App</span> {
<span class='kw'>for</span> <span class='ident'>arg</span> <span class='kw'>in</span> <span class='ident'>args</span>.<span class='ident'>into_iter</span>() {
<span class='self'>self</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>arg</span>(<span class='ident'>arg</span>);
}
<span class='self'>self</span>
}
@ -1023,10 +1027,10 @@
<span class='kw'>unsafe</span> { <span class='ident'>libc</span>::<span class='ident'>exit</span>(<span class='number'>0</span>); }
}
<span class='kw'>fn</span> <span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>msg</span>: <span class='kw-2'>&amp;</span><span class='ident'>String</span>, <span class='ident'>help</span>: <span class='ident'>bool</span>, <span class='ident'>quit</span>: <span class='ident'>bool</span>) {
<span class='kw'>fn</span> <span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>msg</span>: <span class='ident'>String</span>, <span class='ident'>help</span>: <span class='ident'>bool</span>, <span class='ident'>quit</span>: <span class='ident'>bool</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>msg</span>);
<span class='kw'>if</span> <span class='ident'>help</span> { <span class='self'>self</span>.<span class='ident'>print_help</span>(); }
<span class='kw'>if</span> <span class='ident'>quit</span> {<span class='self'>self</span>.<span class='ident'>exit</span>(); }
<span class='kw'>if</span> <span class='ident'>quit</span> { <span class='ident'>env</span>::<span class='ident'>set_exit_status</span>(<span class='number'>1</span>); <span class='self'>self</span>.<span class='ident'>exit</span>(); }
}
<span class='kw'>fn</span> <span class='ident'>print_help</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) {
@ -1035,10 +1039,10 @@
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>pos</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>opts</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>author</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>author</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>author</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>author</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>author</span>);
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>about</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>about</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>about</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>about</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>about</span>);
}
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;&quot;</span>);
@ -1046,24 +1050,24 @@
<span class='macro'>print</span><span class='macro'>!</span>(<span class='string'>&quot;\t{} {} {} {}&quot;</span>, <span class='self'>self</span>.<span class='ident'>name</span>,
<span class='kw'>if</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>is_empty</span>() {<span class='ident'>flags</span> <span class='op'>=</span> <span class='boolval'>true</span>; <span class='string'>&quot;[FLAGS]&quot;</span>} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>},
<span class='kw'>if</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>is_empty</span>() {<span class='ident'>opts</span> <span class='op'>=</span> <span class='boolval'>true</span>; <span class='string'>&quot;[OPTIONS]&quot;</span>} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>},
<span class='kw'>if</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>positionals_name</span>.<span class='ident'>is_empty</span>() {<span class='ident'>pos</span> <span class='op'>=</span> <span class='boolval'>true</span>; <span class='string'>&quot;[POSITIONAL]&quot;</span>} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>});
<span class='kw'>if</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>is_empty</span>() {<span class='ident'>pos</span> <span class='op'>=</span> <span class='boolval'>true</span>; <span class='string'>&quot;[POSITIONAL]&quot;</span>} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>});
<span class='kw'>if</span> <span class='ident'>flags</span> <span class='op'>||</span> <span class='ident'>opts</span> <span class='op'>||</span> <span class='ident'>pos</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;&quot;</span>);
}
<span class='kw'>if</span> <span class='ident'>flags</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;&quot;</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;FLAGS:&quot;</span>);
<span class='kw'>for</span> (_, <span class='ident'>v</span>) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>iter</span>() {
<span class='kw'>for</span> <span class='ident'>v</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>values</span>() {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;\t{}{}\t{}&quot;</span>,
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>short</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{}&quot;</span>,<span class='ident'>s</span>)}<span class='kw'>else</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)},
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>l</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>long</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;,--{}&quot;</span>,<span class='ident'>l</span>)}<span class='kw'>else</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; \t&quot;</span>)},
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>h</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>help</span> {<span class='op'>*</span><span class='ident'>h</span>} <span class='kw'>else</span> {<span class='string'>&quot; &quot;</span>} );
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>short</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{}&quot;</span>,<span class='ident'>s</span>)}<span class='kw'>else</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)},
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>l</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>long</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;,--{}&quot;</span>,<span class='ident'>l</span>)}<span class='kw'>else</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; \t&quot;</span>)},
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>h</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>help</span> {<span class='ident'>h</span>} <span class='kw'>else</span> {<span class='string'>&quot; &quot;</span>} );
}
}
<span class='kw'>if</span> <span class='ident'>opts</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;&quot;</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;OPTIONS:&quot;</span>);
<span class='kw'>for</span> (_, <span class='ident'>v</span>) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>iter</span>() {
<span class='kw'>for</span> <span class='ident'>v</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>values</span>() {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;\t{}{}{}\t\t{}&quot;</span>,
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>short</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{}&quot;</span>,<span class='ident'>s</span>)}<span class='kw'>else</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)},
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>l</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>long</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;,--{}&quot;</span>,<span class='ident'>l</span>)}<span class='kw'>else</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)},
@ -1074,9 +1078,9 @@
<span class='kw'>if</span> <span class='ident'>pos</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;&quot;</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;POSITIONAL ARGUMENTS:&quot;</span>);
<span class='kw'>for</span> (_, <span class='ident'>v</span>) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>iter</span>() {
<span class='kw'>for</span> <span class='ident'>v</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>values</span>() {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;\t{}\t\t\t{}&quot;</span>, <span class='ident'>v</span>.<span class='ident'>name</span>,
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>h</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>help</span> {<span class='op'>*</span><span class='ident'>h</span>} <span class='kw'>else</span> {<span class='string'>&quot; &quot;</span>} );
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>h</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>help</span> {<span class='ident'>h</span>} <span class='kw'>else</span> {<span class='string'>&quot; &quot;</span>} );
}
}
@ -1084,7 +1088,7 @@
}
<span class='kw'>fn</span> <span class='ident'>print_version</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>quit</span>: <span class='ident'>bool</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{} {}&quot;</span>, <span class='self'>self</span>.<span class='ident'>name</span>, <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>v</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>version</span> {<span class='op'>*</span><span class='ident'>v</span>} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>} );
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{} {}&quot;</span>, <span class='self'>self</span>.<span class='ident'>name</span>, <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>v</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>version</span> {<span class='ident'>v</span>} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>} );
<span class='kw'>if</span> <span class='ident'>quit</span> { <span class='self'>self</span>.<span class='ident'>exit</span>(); }
}
@ -1118,7 +1122,7 @@
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>l</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>long</span> {
<span class='kw'>if</span> <span class='op'>*</span><span class='ident'>l</span> <span class='op'>==</span> <span class='ident'>arg</span> {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>contains</span>(<span class='ident'>k</span>) {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument --{} is mutually exclusive with one or more other arguments&quot;</span>, <span class='ident'>arg</span>),
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument --{} is mutually exclusive with one or more other arguments&quot;</span>, <span class='ident'>arg</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
<span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>insert</span>(<span class='ident'>k</span>, <span class='ident'>OptArg</span>{
@ -1150,7 +1154,7 @@
}
<span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>multi</span> {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>contains</span>(<span class='ident'>k</span>) {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument --{} is mutually exclusive with one or more other arguments&quot;</span>, <span class='ident'>arg</span>),
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument --{} is mutually exclusive with one or more other arguments&quot;</span>, <span class='ident'>arg</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
<span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>insert</span>(<span class='ident'>k</span>, <span class='ident'>FlagArg</span>{
@ -1190,7 +1194,7 @@
<span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>found</span> {
<span class='self'>self</span>.<span class='ident'>report_error</span>(
<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Argument --{} isn&#39;t valid&quot;</span>, <span class='ident'>arg</span>),
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Argument --{} isn&#39;t valid&quot;</span>, <span class='ident'>arg</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
<span class='prelude-val'>None</span>
@ -1204,7 +1208,7 @@
<span class='self'>self</span>.<span class='ident'>check_for_help_and_version</span>(<span class='ident'>c</span>);
<span class='kw'>if</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>parse_single_short_flag</span>(<span class='ident'>matches</span>, <span class='ident'>c</span>) {
<span class='self'>self</span>.<span class='ident'>report_error</span>(
<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Argument -{} isn&#39;t valid&quot;</span>,<span class='ident'>c</span>),
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Argument -{} isn&#39;t valid&quot;</span>,<span class='ident'>c</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
}
@ -1223,7 +1227,7 @@
}
<span class='self'>self</span>.<span class='ident'>report_error</span>(
<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Argument -{} isn&#39;t valid&quot;</span>,<span class='ident'>arg_c</span>),
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Argument -{} isn&#39;t valid&quot;</span>,<span class='ident'>arg_c</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
@ -1238,7 +1242,7 @@
<span class='kw'>if</span> <span class='op'>!</span><span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>contains_key</span>(<span class='ident'>k</span>) {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>contains</span>(<span class='ident'>k</span>) {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument -{} is mutually exclusive with one or more other arguments&quot;</span>, <span class='ident'>arg</span>),
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument -{} is mutually exclusive with one or more other arguments&quot;</span>, <span class='ident'>arg</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
<span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>insert</span>(<span class='ident'>k</span>, <span class='ident'>FlagArg</span>{
@ -1286,7 +1290,7 @@
<span class='kw'>for</span> <span class='ident'>name</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>iter</span>() {
<span class='kw'>for</span> (<span class='ident'>k</span>, <span class='ident'>v</span>) <span class='kw'>in</span> <span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>iter</span>() {
<span class='kw'>if</span> <span class='ident'>k</span> <span class='op'>==</span> <span class='ident'>name</span> {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument {} is mutually exclusive with one or more other arguments&quot;</span>,
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument {} is mutually exclusive with one or more other arguments&quot;</span>,
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>short</span> {
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{}&quot;</span>, <span class='ident'>s</span>)
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>l</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>long</span> {
@ -1299,7 +1303,7 @@
}
<span class='kw'>for</span> (<span class='ident'>k</span>, <span class='ident'>v</span>) <span class='kw'>in</span> <span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>iter</span>() {
<span class='kw'>if</span> <span class='ident'>k</span> <span class='op'>==</span> <span class='ident'>name</span> {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument {} is mutually exclusive with one or more other arguments&quot;</span>,
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument {} is mutually exclusive with one or more other arguments&quot;</span>,
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>short</span> {
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{}&quot;</span>, <span class='ident'>s</span>)
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>l</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>long</span> {
@ -1312,7 +1316,7 @@
}
<span class='kw'>for</span> (<span class='ident'>k</span>, <span class='ident'>v</span>) <span class='kw'>in</span> <span class='ident'>matches</span>.<span class='ident'>positionals</span>.<span class='ident'>iter</span>() {
<span class='kw'>if</span> <span class='ident'>k</span> <span class='op'>==</span> <span class='ident'>name</span> {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument \&quot;{}\&quot; is mutually exclusive with one or more other arguments&quot;</span>,<span class='ident'>v</span>.<span class='ident'>name</span>),
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument \&quot;{}\&quot; is mutually exclusive with one or more other arguments&quot;</span>,<span class='ident'>v</span>.<span class='ident'>name</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
}
@ -1320,9 +1324,7 @@
}
}
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_matches</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>ArgMatches</span> {
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>ArgMatches</span>::<span class='ident'>new</span>(<span class='self'>self</span>);
<span class='kw'>fn</span> <span class='ident'>create_help_and_version</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>) {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>needs_long_help</span> {
<span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>insert</span>(<span class='string'>&quot;clap_help&quot;</span>, <span class='ident'>FlagArg</span>{
<span class='ident'>name</span>: <span class='string'>&quot;clap_help&quot;</span>,
@ -1347,18 +1349,24 @@
<span class='ident'>occurrences</span>: <span class='number'>1</span>
});
}
}
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_matches</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>ArgMatches</span> {
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>ArgMatches</span>::<span class='ident'>new</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>);
<span class='self'>self</span>.<span class='ident'>create_help_and_version</span>();
<span class='comment'>// let mut needs_val = false;</span>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>needs_val_of</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='prelude-val'>None</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>pos_counter</span> <span class='op'>=</span> <span class='number'>1</span>;
<span class='kw'>for</span> <span class='ident'>arg</span> <span class='kw'>in</span> <span class='ident'>env</span>::<span class='ident'>args</span>().<span class='ident'>collect</span>::<span class='op'>&lt;</span><span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>String</span><span class='op'>&gt;&gt;</span>().<span class='ident'>tail</span>() {
<span class='kw'>for</span> <span class='ident'>arg</span> <span class='kw'>in</span> <span class='ident'>env</span>::<span class='ident'>args</span>().<span class='ident'>collect</span>::<span class='op'>&lt;</span><span class='ident'>Vec</span><span class='op'>&lt;</span>_<span class='op'>&gt;&gt;</span>().<span class='ident'>tail</span>() {
<span class='kw'>let</span> <span class='ident'>arg_slice</span> <span class='op'>=</span> <span class='ident'>arg</span>.<span class='ident'>as_slice</span>();
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>skip</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>nvo</span>) <span class='op'>=</span> <span class='ident'>needs_val_of</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>nvo</span>) <span class='op'>=</span> <span class='ident'>needs_val_of</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>opt</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>get</span>(<span class='ident'>nvo</span>) {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>contains</span>(<span class='ident'>opt</span>.<span class='ident'>name</span>) {
<span class='self'>self</span>.<span class='ident'>report_error</span>(
<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument {} is mutually exclusive with one or more other arguments&quot;</span>,
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument {} is mutually exclusive with one or more other arguments&quot;</span>,
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>long</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>long</span> {
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;--{}&quot;</span>,<span class='ident'>long</span>)
}<span class='kw'>else</span>{
@ -1411,14 +1419,14 @@
} <span class='kw'>else</span> {
<span class='comment'>// Positional</span>
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>is_empty</span>() <span class='op'>||</span> <span class='self'>self</span>.<span class='ident'>positionals_name</span>.<span class='ident'>is_empty</span>() {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>is_empty</span>() { <span class='comment'>// || self.positionals_name.is_empty() {</span>
<span class='self'>self</span>.<span class='ident'>report_error</span>(
<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Found positional argument {}, but {} doesn&#39;t accept any&quot;</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>name</span>),
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Found positional argument {}, but {} doesn&#39;t accept any&quot;</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>name</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>p</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>get</span>(<span class='kw-2'>&amp;</span><span class='ident'>pos_counter</span>) {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>contains</span>(<span class='ident'>p</span>.<span class='ident'>name</span>) {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument \&quot;{}\&quot; is mutually exclusive with one or more other arguments&quot;</span>, <span class='ident'>arg</span>),
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument \&quot;{}\&quot; is mutually exclusive with one or more other arguments&quot;</span>, <span class='ident'>arg</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
<span class='ident'>matches</span>.<span class='ident'>positionals</span>.<span class='ident'>insert</span>(<span class='ident'>p</span>.<span class='ident'>name</span>, <span class='ident'>PosArg</span>{
@ -1452,7 +1460,7 @@
}
<span class='ident'>pos_counter</span> <span class='op'>+=</span> <span class='number'>1</span>;
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Positional argument \&quot;{}\&quot; was found, but {} wasn&#39;t expecting any&quot;</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>name</span>), <span class='boolval'>false</span>, <span class='boolval'>true</span>);
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Positional argument \&quot;{}\&quot; was found, but {} wasn&#39;t expecting any&quot;</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>name</span>), <span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
}
}
@ -1460,13 +1468,13 @@
<span class='kw'>match</span> <span class='ident'>needs_val_of</span> {
<span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>) <span class='op'>=&gt;</span> {
<span class='self'>self</span>.<span class='ident'>report_error</span>(
<span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Argument \&quot;{}\&quot; requires a value but none was supplied&quot;</span>, <span class='ident'>a</span>),
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Argument \&quot;{}\&quot; requires a value but none was supplied&quot;</span>, <span class='ident'>a</span>),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}
_ <span class='op'>=&gt;</span> {}
}
<span class='kw'>if</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>is_empty</span>() {
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='string'>&quot;One or more required arguments were not supplied&quot;</span>.<span class='ident'>to_string</span>(),
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='string'>&quot;One or more required arguments were not supplied&quot;</span>.<span class='ident'>to_string</span>(),
<span class='boolval'>false</span>, <span class='boolval'>true</span>);
}

View file

@ -485,7 +485,7 @@
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .short(&quot;c&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>short</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>short</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>short</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>)
.<span class='ident'>char_at</span>(<span class='number'>0</span>));
<span class='self'>self</span>
@ -510,7 +510,7 @@
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .long(&quot;config&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>long</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>l</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>long</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>l</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>long</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>l</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>));
<span class='self'>self</span>
}
@ -527,7 +527,7 @@
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .help(&quot;The config file used by the myprog&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>help</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>h</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>help</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>h</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>help</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>h</span>);
<span class='self'>self</span>
}
@ -550,7 +550,7 @@
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .required(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>required</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>r</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>required</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>r</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>required</span> <span class='op'>=</span> <span class='ident'>r</span>;
<span class='self'>self</span>
}
@ -569,7 +569,7 @@
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .mutually_excludes(&quot;debug&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>blacklist</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>name</span>);
} <span class='kw'>else</span> {
@ -593,7 +593,7 @@
<span class='doccomment'>/// .mutually_excludes_all(</span>
<span class='doccomment'>/// vec![&quot;debug&quot;, &quot;input&quot;])</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes_all</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes_all</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>blacklist</span> {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>names</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>n</span>);
@ -616,7 +616,7 @@
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .requires(&quot;debug&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>requires</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>name</span>);
} <span class='kw'>else</span> {
@ -639,7 +639,7 @@
<span class='doccomment'>/// .requires_all(</span>
<span class='doccomment'>/// vec![&quot;debug&quot;, &quot;input&quot;])</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires_all</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires_all</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>requires</span> {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>names</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>n</span>);
@ -664,7 +664,7 @@
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .takes_value(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>takes_value</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>tv</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>takes_value</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>tv</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>==</span> <span class='prelude-val'>None</span>);
<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>=</span> <span class='ident'>tv</span>;
<span class='self'>self</span>
@ -686,7 +686,7 @@
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .index(1)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>index</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>idx</span>: <span class='ident'>u8</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>index</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>idx</span>: <span class='ident'>u8</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>==</span> <span class='boolval'>false</span>);
<span class='kw'>if</span> <span class='ident'>idx</span> <span class='op'>&lt;</span> <span class='number'>1</span> { <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument index must start at 1&quot;</span>); }
<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>idx</span>);
@ -710,7 +710,7 @@
<span class='doccomment'>/// # Arg::new(&quot;debug&quot;)</span>
<span class='doccomment'>/// .multiple(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>multiple</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>multi</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Arg</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>multiple</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>multi</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>==</span> <span class='boolval'>false</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>==</span> <span class='prelude-val'>None</span>);
<span class='self'>self</span>.<span class='ident'>multiple</span> <span class='op'>=</span> <span class='ident'>multi</span>;

View file

@ -305,7 +305,7 @@
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>pos</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>positionals</span>.<span class='ident'>get</span>(<span class='ident'>name</span>) {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>v</span>) <span class='op'>=</span> <span class='ident'>pos</span>.<span class='ident'>value</span> {
<span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>v</span>);
}
}
}
<span class='prelude-val'>None</span>
}

View file

@ -156,6 +156,26 @@
<span id="114">114</span>
<span id="115">115</span>
<span id="116">116</span>
<span id="117">117</span>
<span id="118">118</span>
<span id="119">119</span>
<span id="120">120</span>
<span id="121">121</span>
<span id="122">122</span>
<span id="123">123</span>
<span id="124">124</span>
<span id="125">125</span>
<span id="126">126</span>
<span id="127">127</span>
<span id="128">128</span>
<span id="129">129</span>
<span id="130">130</span>
<span id="131">131</span>
<span id="132">132</span>
<span id="133">133</span>
<span id="134">134</span>
<span id="135">135</span>
<span id="136">136</span>
</pre><pre class='rust '>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>crate_type</span><span class='op'>=</span> <span class='string'>&quot;lib&quot;</span>]</span>
@ -250,27 +270,47 @@
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span>
<span class='kw'>mod</span> <span class='ident'>tests</span> {
<span class='kw'>use</span> <span class='ident'>super</span>::<span class='op'>*</span>;
<span class='kw'>use</span> <span class='ident'>super</span>::<span class='op'>*</span>;
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_fail</span>]</span>
<span class='kw'>fn</span> <span class='ident'>non_unique_arg_names</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;test_app&quot;</span>).<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;s&quot;</span>))
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>));
<span class='kw'>fn</span> <span class='ident'>unique_arg_names</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;b&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_fail</span>]</span>
<span class='kw'>fn</span> <span class='ident'>non_unique_shorts</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;test_app&quot;</span>).<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;s&quot;</span>))
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;other&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;s&quot;</span>));
<span class='kw'>fn</span> <span class='ident'>unique_arg_shorts</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg1&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg2&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_fail</span>]</span>
<span class='kw'>fn</span> <span class='ident'>non_unique_longs</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;test_app&quot;</span>).<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>))
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;other&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>));
<span class='kw'>fn</span> <span class='ident'>unique_arg_longs</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg1&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg2&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_app</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>about</span>(<span class='string'>&quot;about&quot;</span>).<span class='ident'>author</span>(<span class='string'>&quot;author&quot;</span>).<span class='ident'>version</span>(<span class='string'>&quot;1.0&quot;</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_flag</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>multiple</span>(<span class='boolval'>true</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_pos</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>index</span>(<span class='number'>1</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_opt</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;s&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>takes_value</span>(<span class='boolval'>true</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
}
}
</pre>