chore(docs): rebuild documentation with new from_usage features

This commit is contained in:
Kevin K 2015-04-13 15:36:21 -04:00
parent 0d3ecd8e83
commit 22163991da
10 changed files with 1646 additions and 14 deletions

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-341'>[src]</a></span></h1>
</span><a id='src-0' href='../src/clap/lib.rs.html#1-901'>[src]</a></span></h1>
<div class='docblock'>
<h1 id="clap" class='section-header'><a
href="#clap">clap</a></h1>
@ -57,6 +57,8 @@
href="#video-tutorials">Video Tutorials</a></h2>
<p>I&#39;ve been working on a few short video tutorials about using <code>clap</code>. They&#39;re located on <a href="https://www.youtube.com/playlist?list=PLza5oFLQGTl0Bc_EU_pBNcX-rhVqDTRxv">youtube</a>. </p>
<p><em>Note</em>: The videos have not been updated to include the new <code>from_usage()</code> methods which make building args significantly less verbose. New videos will be added soon.</p>
<p><em>Note</em>: Apologies for the resolution of the first video, it will be updated to a better resolution soon. The other videos have a proper resolution.</p>
<h2 id="about" class='section-header'><a
@ -125,7 +127,58 @@
<h2 id="quick-example" class='section-header'><a
href="#quick-example">Quick Example</a></h2>
<p>The following shows a quick example of some of the basic functionality of <code>clap</code>. For more advanced usage, such as requirements, exclusions, multiple values and occurrences see the <a href="https://www.youtube.com/playlist?list=PLza5oFLQGTl0Bc_EU_pBNcX-rhVqDTRxv">video tutorials</a>, <a href="http://kbknapp.github.io/clap-rs/docs/clap/index.html">documentation</a>, or <code>examples/</code> directory of this repository.</p>
<p>The following two examples (which are functionally equivilant, but show two different ways to use <code>clap</code>) show a quick example of some of the basic functionality of <code>clap</code>. For more advanced usage, such as requirements, exclusions, multiple values and occurrences see the <a href="https://www.youtube.com/playlist?list=PLza5oFLQGTl0Bc_EU_pBNcX-rhVqDTRxv">video tutorials</a>, <a href="http://kbknapp.github.io/clap-rs/docs/clap/index.html">documentation</a>, or <code>examples/</code> directory of this repository.</p>
<pre id='rust-example-rendered' class='rust '>
<span class='comment'>// (Full example with comments in examples/01_QuickExample.rs)</span>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>clap</span>;
<span class='kw'>use</span> <span class='ident'>clap</span>::{<span class='ident'>Arg</span>, <span class='ident'>App</span>, <span class='ident'>SubCommand</span>};
<span class='kw'>fn</span> <span class='ident'>main</span>() {
<span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;myapp&quot;</span>)
.<span class='ident'>version</span>(<span class='string'>&quot;1.0&quot;</span>)
.<span class='ident'>author</span>(<span class='string'>&quot;Kevin K. &lt;kbknapp@gmail.com&gt;&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Does awesome things&quot;</span>)
.<span class='ident'>args_from_usage</span>(
<span class='string'>&quot;-c --config=[CONFIG] &#39;Sets a custom config file&#39;
&lt;INPUT&gt; &#39;Sets the input file to use&#39;
[debug]... -d &#39;Sets the level of debugging information&#39;&quot;</span>)
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;test&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;controls testing features&quot;</span>)
.<span class='ident'>version</span>(<span class='string'>&quot;1.3&quot;</span>)
.<span class='ident'>author</span>(<span class='string'>&quot;Someone E. &lt;someone_else@other.com&gt;&quot;</span>)
.<span class='ident'>arg_from_usage</span>(<span class='string'>&quot;-v --verbose &#39;Print test information verbosely&#39;&quot;</span>))
.<span class='ident'>get_matches</span>();
<span class='comment'>// Calling .unwrap() is safe here because &quot;INPUT&quot; is required (if &quot;INPUT&quot; wasn&#39;t</span>
<span class='comment'>// required we could have used an &#39;if let&#39; to conditionally get the value)</span>
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Using input file: {}&quot;</span>, <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;INPUT&quot;</span>).<span class='ident'>unwrap</span>());
<span class='comment'>// Gets a value for config if supplied by user, or defaults to &quot;default.conf&quot;</span>
<span class='kw'>let</span> <span class='ident'>config</span> <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;CONFIG&quot;</span>).<span class='ident'>unwrap_or</span>(<span class='string'>&quot;default.conf&quot;</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Value for config: {}&quot;</span>, <span class='ident'>config</span>);
<span class='comment'>// Vary the output based on how many times the user used the &quot;debug&quot; flag</span>
<span class='comment'>// (i.e. &#39;myapp -d -d -d&#39; or &#39;myapp -ddd&#39; vs &#39;myapp -d&#39; </span>
<span class='kw'>match</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>&quot;debug&quot;</span>) {
<span class='number'>0</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is off&quot;</span>),
<span class='number'>1</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is kind of on&quot;</span>),
<span class='number'>2</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is on&quot;</span>),
<span class='number'>3</span> <span class='op'>|</span> _ <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Don&#39;t be crazy&quot;</span>),
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>matches</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>subcommand_matches</span>(<span class='string'>&quot;test&quot;</span>) {
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>is_present</span>(<span class='string'>&quot;verbose&quot;</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Printing verbosely...&quot;</span>);
} <span class='kw'>else</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Printing normally...&quot;</span>);
}
}
<span class='comment'>// more porgram logic goes here...</span>
}
</pre>
<p>While the following example is functionally the same as the one above, this method allows more advanced configuration options, or even dynamically generating arguments when desired. Both methods can be used together to get the best of both worlds (see the documentation).</p>
<pre id='rust-example-rendered' class='rust '>
<span class='comment'>// (Full example with comments in examples/01_QuickExample.rs)</span>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>clap</span>;
@ -148,7 +201,7 @@
.<span class='ident'>arg</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>)
.<span class='ident'>multiple</span>(<span class='boolval'>true</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Turn debugging information on&quot;</span>))
.<span class='ident'>help</span>(<span class='string'>&quot;Sets the level of debugging information&quot;</span>))
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;test&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;controls testing features&quot;</span>)
.<span class='ident'>version</span>(<span class='string'>&quot;1.3&quot;</span>)
@ -187,7 +240,7 @@
}
</pre>
<p>If you were to compile the above program and run it with the flag <code>--help</code> or <code>-h</code> (or <code>help</code> subcommand, since we defined <code>test</code> as a subcommand) the following would be output</p>
<p>If you were to compile either of the above programs and run them with the flag <code>--help</code> or <code>-h</code> (or <code>help</code> subcommand, since we defined <code>test</code> as a subcommand) the following would be output</p>
<pre><code class="language-sh">$ myapp --help
myapp 1.0

View file

@ -1 +1 @@
{"name":"clap","counts":{"deprecated":0,"unstable":0,"stable":0,"unmarked":41},"submodules":[]}
{"name":"clap","counts":{"deprecated":0,"unstable":0,"stable":0,"unmarked":45},"submodules":[]}

View file

@ -131,6 +131,24 @@ showing the usage.</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.arg_from_usage' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.arg_from_usage' class='fnname'>arg_from_usage</a>(self, usage: &amp;'ar <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>&lt;'a, 'v, 'ab, 'u, 'ar&gt;</code></h4>
<div class='docblock'><p>Adds an argument from a usage string. See Arg::from_usage() for details</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<span class='ident'>arg_from_usage</span>(<span class='string'>&quot;-c --conf=&lt;config&gt; &#39;Sets a configuration file to use&#39;&quot;</span>)
</pre>
</div><h4 id='method.args_from_usage' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.args_from_usage' class='fnname'>args_from_usage</a>(self, usage: &amp;'ar <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>&lt;'a, 'v, 'ab, 'u, 'ar&gt;</code></h4>
<div class='docblock'><p>Adds multiple arguments from a usage string, one per line. See Arg::from_usage() for
details</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<span class='ident'>args_from_usage</span>(
<span class='string'>&quot;-c --conf=[config] &#39;Sets a configuration file to use&#39;
[debug]... -d &#39;Sets the debugging level&#39;
&lt;input&gt; &#39;The input file to use&#39;&quot;</span>)
</pre>
</div><h4 id='method.subcommand' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.subcommand' class='fnname'>subcommand</a>(self, subcmd: <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&lt;'a, 'v, 'ab, 'u, 'ar&gt;) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&lt;'a, 'v, 'ab, 'u, 'ar&gt;</code></h4>
<div class='docblock'><p>Adds a subcommand to the list of valid possibilties. Subcommands are effectively sub apps,
because they can contain their own arguments, subcommands, version, usage, etc. They also

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-8364' href='../src/clap/args/arg.rs.html#21-66'>[src]</a></span></h1>
</span><a id='src-8420' href='../src/clap/args/arg.rs.html#23-68'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Arg&lt;'n, 'l, 'h, 'b, 'p, 'r&gt; {
// some fields omitted
}</pre><div class='docblock'><p>The abstract representation of a command line argument used by the consumer of the library.
@ -70,10 +70,69 @@ whether or not the argument was used at runtime. </p>
and positional arguments (i.e. those without a <code>-</code> or <code>--</code>) the name will also
be displayed when the user prints the usage/help information of the program.</p>
<p><strong>NOTE:</strong> this function is deprecated in favor of Arg::with_name() to stay in line with
Rust APIs</p>
<p>Example:</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.with_name' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.with_name' class='fnname'>with_name</a>(n: &amp;'n <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>&lt;'n, 'l, 'h, 'b, 'p, 'r&gt;</code></h4>
<div class='docblock'><p>Creates a new instace of <code>Arg</code> using a unique string name.
The name will be used by the library consumer to get information about
whether or not the argument was used at runtime. </p>
<p><strong>NOTE:</strong> in the case of arguments that take values (i.e. <code>takes_value(true)</code>)
and positional arguments (i.e. those without a <code>-</code> or <code>--</code>) the name will also
be displayed when the user prints the usage/help information of the program.</p>
<p>Example:</p>
<pre id='rust-example-rendered' class='rust '>
<span class='ident'>Arg</span>::<span class='ident'>with_name</span>(<span class='string'>&quot;conifg&quot;</span>)
</pre>
</div><h4 id='method.from_usage' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.from_usage' class='fnname'>from_usage</a>(u: &amp;'n <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>&lt;'n, 'n, 'n, 'b, 'p, 'r&gt;</code></h4>
<div class='docblock'><p>Creates a new instace of <code>Arg</code> using a usage string. Allows creation of basic settings
for Arg (i.e. everything except relational rules). The syntax is flexible, but there are
some rules to follow.</p>
<p>The syntax should be as follows (only properties which you wish to set must be present):</p>
<ol>
<li>Name (arguments with a <code>long</code> or that take a value can ommit this if desired),
use <code>[]</code> for non-required arguments, or <code>&lt;&gt;</code> for required arguments.</li>
<li>Short preceded by a <code>-</code></li>
<li>Long preceded by a <code>--</code> (this may be used as the name, if the name is omitted. If the
name is <em>not</em> omittied, the name takes precedence)</li>
<li>Value (this can be used as the name, if the name is not manually specified. If the name
is manually specified, it takes precence. If this value is used as the name, it uses the
same <code>[]</code> and <code>&lt;&gt;</code> requirement rules. If it is <em>not</em> used as the name, it still needs to
be surrounded by either <code>[]</code> or <code>&lt;&gt;</code> but the effect is the same, as the requirement rule
is determined by the name. The value may follow the <code>short</code> or <code>long</code>. If it
follows the <code>long</code>, it may follow either a <code>=</code> or <code></code> with the same effect, personal
preference only, but may only follow a <code></code> after a <code>short</code>)</li>
<li>Multiple specifier <code>...</code> (for flags or positional arguments the <code>...</code> may follow the
name or <code>short</code> or <code>long</code>)</li>
<li>The help info surrounded by <code>&#39;</code></li>
<li>The index of a positional argument will be the next available index (you don&#39;t need to
specify one)</li>
</ol>
<p>Example:</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='comment'>// A option argument with a long, named &quot;conf&quot; (note: because the name was specified</span>
<span class='comment'>// the portion after the long can be called anything, only the first name will be displayed</span>
<span class='comment'>// to the user. Also, requirement is set with the *name*, so the portion after the long could</span>
<span class='comment'>// be either &lt;&gt; or [] and it wouldn&#39;t matter, so long as it&#39;s one of them. Had the name been</span>
<span class='comment'>// omitted, the name would have been derived from the portion after the long and those rules</span>
<span class='comment'>// would have mattered)</span>
<span class='ident'>Arg</span>::<span class='ident'>from_usage</span>(<span class='string'>&quot;[conf] --config=[c] &#39;a required file for the configuration&#39;&quot;</span>),
<span class='comment'>// A flag with a short, a long, named &quot;debug&quot;, and accepts multiple values</span>
<span class='ident'>Arg</span>::<span class='ident'>from_usage</span>(<span class='string'>&quot;-d --debug... &#39;turns on debugging information&quot;</span>),
<span class='comment'>// A required positional argument named &quot;input&quot;</span>
<span class='ident'>Arg</span>::<span class='ident'>from_usage</span>(<span class='string'>&quot;&lt;input&gt; &#39;the input file to use&#39;&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>(self, s: &amp;<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>&lt;'n, 'l, 'h, 'b, 'p, 'r&gt;</code></h4>
<div class='docblock'><p>Sets the short version of the argument without the preceding <code>-</code>.</p>

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-8945' href='../src/clap/args/argmatches.rs.html#57-68'>[src]</a></span></h1>
</span><a id='src-9280' href='../src/clap/args/argmatches.rs.html#57-68'>[src]</a></span></h1>
<pre class='rust struct'>pub struct ArgMatches&lt;'a&gt; {
// some fields omitted
}</pre><div class='docblock'><p>Used to get information about the arguments that where supplied to the program at runtime by

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=''>SubCommand</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-9436' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
</span><a id='src-9771' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
<pre class='rust struct'>pub struct SubCommand&lt;'a&gt; {
pub name: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a>,
pub matches: <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;,

File diff suppressed because one or more lines are too long

View file

@ -1301,6 +1301,48 @@
<span id="1259">1259</span>
<span id="1260">1260</span>
<span id="1261">1261</span>
<span id="1262">1262</span>
<span id="1263">1263</span>
<span id="1264">1264</span>
<span id="1265">1265</span>
<span id="1266">1266</span>
<span id="1267">1267</span>
<span id="1268">1268</span>
<span id="1269">1269</span>
<span id="1270">1270</span>
<span id="1271">1271</span>
<span id="1272">1272</span>
<span id="1273">1273</span>
<span id="1274">1274</span>
<span id="1275">1275</span>
<span id="1276">1276</span>
<span id="1277">1277</span>
<span id="1278">1278</span>
<span id="1279">1279</span>
<span id="1280">1280</span>
<span id="1281">1281</span>
<span id="1282">1282</span>
<span id="1283">1283</span>
<span id="1284">1284</span>
<span id="1285">1285</span>
<span id="1286">1286</span>
<span id="1287">1287</span>
<span id="1288">1288</span>
<span id="1289">1289</span>
<span id="1290">1290</span>
<span id="1291">1291</span>
<span id="1292">1292</span>
<span id="1293">1293</span>
<span id="1294">1294</span>
<span id="1295">1295</span>
<span id="1296">1296</span>
<span id="1297">1297</span>
<span id="1298">1298</span>
<span id="1299">1299</span>
<span id="1300">1300</span>
<span id="1301">1301</span>
<span id="1302">1302</span>
<span id="1303">1303</span>
</pre><pre class='rust '>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeMap</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeSet</span>;
@ -1523,10 +1565,13 @@
<span class='kw'>if</span> <span class='ident'>a</span>.<span class='ident'>required</span> {
<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='kw'>if</span> <span class='ident'>a</span>.<span class='ident'>index</span>.<span class='ident'>is_some</span>() <span class='op'>||</span> (<span class='ident'>a</span>.<span class='ident'>short</span>.<span class='ident'>is_none</span>() <span class='op'>&amp;&amp;</span> <span class='ident'>a</span>.<span class='ident'>long</span>.<span class='ident'>is_none</span>()) {
<span class='kw'>let</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='ident'>a</span>.<span class='ident'>index</span>.<span class='ident'>is_none</span>() {(<span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>len</span>() <span class='op'>+</span> <span class='number'>1</span>) <span class='kw'>as</span> <span class='ident'>u8</span> } <span class='kw'>else</span> { <span class='ident'>a</span>.<span class='ident'>index</span>.<span class='ident'>unwrap</span>() };
<span class='kw'>if</span> <span class='ident'>a</span>.<span class='ident'>short</span>.<span class='ident'>is_some</span>() <span class='op'>||</span> <span class='ident'>a</span>.<span class='ident'>long</span>.<span class='ident'>is_some</span>() {
<span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument \&quot;{}\&quot; has conflicting requirements, both index() and short(), or long(), were supplied&quot;</span>, <span class='ident'>a</span>.<span class='ident'>name</span>);
}
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>contains_key</span>(<span class='kw-2'>&amp;</span><span class='ident'>i</span>) {
<span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument \&quot;{}\&quot; has the same index as another positional argument&quot;</span>, <span class='ident'>a</span>.<span class='ident'>name</span>);
}
@ -1534,6 +1579,7 @@
<span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument \&quot;{}\&quot; has conflicting requirements, both index() and takes_value(true) were supplied&quot;</span>, <span class='ident'>a</span>.<span class='ident'>name</span>);
}
<span class='comment'>// Create the Positional Arguemnt Builder with each HashSet = None to only allocate those that require it</span>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>pb</span> <span class='op'>=</span> <span class='ident'>PosBuilder</span> {
<span class='ident'>name</span>: <span class='ident'>a</span>.<span class='ident'>name</span>,
@ -1608,7 +1654,8 @@
<span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>insert</span>(<span class='ident'>a</span>.<span class='ident'>name</span>, <span class='ident'>ob</span>);
} <span class='kw'>else</span> {
<span class='kw'>if</span> <span class='ident'>a</span>.<span class='ident'>short</span>.<span class='ident'>is_none</span>() <span class='op'>&amp;&amp;</span> <span class='ident'>a</span>.<span class='ident'>long</span>.<span class='ident'>is_none</span>() {
<span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument \&quot;{}\&quot; must have either a short() and/or long() supplied since no index() or takes_value() were found&quot;</span>, <span class='ident'>a</span>.<span class='ident'>name</span>);
<span class='comment'>// Could be a posistional constructed from usage string</span>
}
<span class='kw'>if</span> <span class='ident'>a</span>.<span class='ident'>required</span> {
<span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument \&quot;{}\&quot; cannot be required(true) because it has no index() or takes_value(true)&quot;</span>, <span class='ident'>a</span>.<span class='ident'>name</span>);
@ -1664,6 +1711,43 @@
<span class='self'>self</span>
}
<span class='doccomment'>/// Adds an argument from a usage string. See Arg::from_usage() for details</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let app = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// .arg_from_usage(&quot;-c --conf=&lt;config&gt; &#39;Sets a configuration file to use&#39;&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'>arg_from_usage</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>usage</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;ar</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>App</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span>, <span class='lifetime'>&#39;v</span>, <span class='lifetime'>&#39;ab</span>, <span class='lifetime'>&#39;u</span>, <span class='lifetime'>&#39;ar</span><span class='op'>&gt;</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='ident'>from_usage</span>(<span class='ident'>usage</span>));
<span class='self'>self</span>
}
<span class='doccomment'>/// Adds multiple arguments from a usage string, one per line. See Arg::from_usage() for</span>
<span class='doccomment'>/// details</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let app = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// .args_from_usage(</span>
<span class='doccomment'>/// &quot;-c --conf=[config] &#39;Sets a configuration file to use&#39;</span>
<span class='doccomment'>/// [debug]... -d &#39;Sets the debugging level&#39;</span>
<span class='doccomment'>/// &lt;input&gt; &#39;The input file to use&#39;&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_from_usage</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>usage</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;ar</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>App</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span>, <span class='lifetime'>&#39;v</span>, <span class='lifetime'>&#39;ab</span>, <span class='lifetime'>&#39;u</span>, <span class='lifetime'>&#39;ar</span><span class='op'>&gt;</span> {
<span class='kw'>for</span> <span class='ident'>l</span> <span class='kw'>in</span> <span class='ident'>usage</span>.<span class='ident'>lines</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='ident'>from_usage</span>(<span class='ident'>l</span>));
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Adds a subcommand to the list of valid possibilties. Subcommands are effectively sub apps,</span>
<span class='doccomment'>/// because they can contain their own arguments, subcommands, version, usage, etc. They also</span>
<span class='doccomment'>/// function just like apps, in that they get their own auto generated help and version</span>

View file

@ -411,7 +411,158 @@
<span id="369">369</span>
<span id="370">370</span>
<span id="371">371</span>
<span id="372">372</span>
<span id="373">373</span>
<span id="374">374</span>
<span id="375">375</span>
<span id="376">376</span>
<span id="377">377</span>
<span id="378">378</span>
<span id="379">379</span>
<span id="380">380</span>
<span id="381">381</span>
<span id="382">382</span>
<span id="383">383</span>
<span id="384">384</span>
<span id="385">385</span>
<span id="386">386</span>
<span id="387">387</span>
<span id="388">388</span>
<span id="389">389</span>
<span id="390">390</span>
<span id="391">391</span>
<span id="392">392</span>
<span id="393">393</span>
<span id="394">394</span>
<span id="395">395</span>
<span id="396">396</span>
<span id="397">397</span>
<span id="398">398</span>
<span id="399">399</span>
<span id="400">400</span>
<span id="401">401</span>
<span id="402">402</span>
<span id="403">403</span>
<span id="404">404</span>
<span id="405">405</span>
<span id="406">406</span>
<span id="407">407</span>
<span id="408">408</span>
<span id="409">409</span>
<span id="410">410</span>
<span id="411">411</span>
<span id="412">412</span>
<span id="413">413</span>
<span id="414">414</span>
<span id="415">415</span>
<span id="416">416</span>
<span id="417">417</span>
<span id="418">418</span>
<span id="419">419</span>
<span id="420">420</span>
<span id="421">421</span>
<span id="422">422</span>
<span id="423">423</span>
<span id="424">424</span>
<span id="425">425</span>
<span id="426">426</span>
<span id="427">427</span>
<span id="428">428</span>
<span id="429">429</span>
<span id="430">430</span>
<span id="431">431</span>
<span id="432">432</span>
<span id="433">433</span>
<span id="434">434</span>
<span id="435">435</span>
<span id="436">436</span>
<span id="437">437</span>
<span id="438">438</span>
<span id="439">439</span>
<span id="440">440</span>
<span id="441">441</span>
<span id="442">442</span>
<span id="443">443</span>
<span id="444">444</span>
<span id="445">445</span>
<span id="446">446</span>
<span id="447">447</span>
<span id="448">448</span>
<span id="449">449</span>
<span id="450">450</span>
<span id="451">451</span>
<span id="452">452</span>
<span id="453">453</span>
<span id="454">454</span>
<span id="455">455</span>
<span id="456">456</span>
<span id="457">457</span>
<span id="458">458</span>
<span id="459">459</span>
<span id="460">460</span>
<span id="461">461</span>
<span id="462">462</span>
<span id="463">463</span>
<span id="464">464</span>
<span id="465">465</span>
<span id="466">466</span>
<span id="467">467</span>
<span id="468">468</span>
<span id="469">469</span>
<span id="470">470</span>
<span id="471">471</span>
<span id="472">472</span>
<span id="473">473</span>
<span id="474">474</span>
<span id="475">475</span>
<span id="476">476</span>
<span id="477">477</span>
<span id="478">478</span>
<span id="479">479</span>
<span id="480">480</span>
<span id="481">481</span>
<span id="482">482</span>
<span id="483">483</span>
<span id="484">484</span>
<span id="485">485</span>
<span id="486">486</span>
<span id="487">487</span>
<span id="488">488</span>
<span id="489">489</span>
<span id="490">490</span>
<span id="491">491</span>
<span id="492">492</span>
<span id="493">493</span>
<span id="494">494</span>
<span id="495">495</span>
<span id="496">496</span>
<span id="497">497</span>
<span id="498">498</span>
<span id="499">499</span>
<span id="500">500</span>
<span id="501">501</span>
<span id="502">502</span>
<span id="503">503</span>
<span id="504">504</span>
<span id="505">505</span>
<span id="506">506</span>
<span id="507">507</span>
<span id="508">508</span>
<span id="509">509</span>
<span id="510">510</span>
<span id="511">511</span>
<span id="512">512</span>
<span id="513">513</span>
<span id="514">514</span>
<span id="515">515</span>
<span id="516">516</span>
<span id="517">517</span>
<span id="518">518</span>
<span id="519">519</span>
<span id="520">520</span>
</pre><pre class='rust '>
<span class='kw'>use</span> <span class='ident'>usageparser</span>::{<span class='ident'>UsageParser</span>, <span class='ident'>UsageToken</span>};
<span class='doccomment'>/// The abstract representation of a command line argument used by the consumer of the library.</span>
<span class='doccomment'>/// Used to set all the options and relationships that define a valid argument for the program.</span>
<span class='doccomment'>/// </span>
@ -488,6 +639,9 @@
<span class='doccomment'>/// and positional arguments (i.e. those without a `-` or `--`) the name will also </span>
<span class='doccomment'>/// be displayed when the user prints the usage/help information of the program.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** this function is deprecated in favor of Arg::with_name() to stay in line with</span>
<span class='doccomment'>/// Rust APIs</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
@ -497,6 +651,8 @@
<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='attribute'>#[<span class='ident'>deprecated</span>(<span class='ident'>since</span> <span class='op'>=</span> <span class='string'>&quot;0.5.15&quot;</span>,
<span class='ident'>reason</span> <span class='op'>=</span> <span class='string'>&quot;use Arg::with_name() instead&quot;</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>n</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;n</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span><span class='op'>&lt;</span><span class='lifetime'>&#39;n</span>, <span class='lifetime'>&#39;l</span>, <span class='lifetime'>&#39;h</span>, <span class='lifetime'>&#39;b</span>, <span class='lifetime'>&#39;p</span>, <span class='lifetime'>&#39;r</span><span class='op'>&gt;</span> {
<span class='ident'>Arg</span> {
<span class='ident'>name</span>: <span class='ident'>n</span>,
@ -513,6 +669,148 @@
}
}
<span class='doccomment'>/// Creates a new instace of `Arg` using a unique string name. </span>
<span class='doccomment'>/// The name will be used by the library consumer to get information about</span>
<span class='doccomment'>/// whether or not the argument was used at runtime. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** in the case of arguments that take values (i.e. `takes_value(true)`)</span>
<span class='doccomment'>/// and positional arguments (i.e. those without a `-` or `--`) the name will also </span>
<span class='doccomment'>/// be displayed when the user prints the usage/help information of the program.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// Arg::with_name(&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'>with_name</span>(<span class='ident'>n</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;n</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span><span class='op'>&lt;</span><span class='lifetime'>&#39;n</span>, <span class='lifetime'>&#39;l</span>, <span class='lifetime'>&#39;h</span>, <span class='lifetime'>&#39;b</span>, <span class='lifetime'>&#39;p</span>, <span class='lifetime'>&#39;r</span><span class='op'>&gt;</span> {
<span class='ident'>Arg</span> {
<span class='ident'>name</span>: <span class='ident'>n</span>,
<span class='ident'>short</span>: <span class='prelude-val'>None</span>,
<span class='ident'>long</span>: <span class='prelude-val'>None</span>,
<span class='ident'>help</span>: <span class='prelude-val'>None</span>,
<span class='ident'>required</span>: <span class='boolval'>false</span>,
<span class='ident'>takes_value</span>: <span class='boolval'>false</span>,
<span class='ident'>multiple</span>: <span class='boolval'>false</span>,
<span class='ident'>index</span>: <span class='prelude-val'>None</span>,
<span class='ident'>possible_vals</span>: <span class='prelude-val'>None</span>,
<span class='ident'>blacklist</span>: <span class='prelude-val'>None</span>,
<span class='ident'>requires</span>: <span class='prelude-val'>None</span>,
}
}
<span class='doccomment'>/// Creates a new instace of `Arg` using a usage string. Allows creation of basic settings</span>
<span class='doccomment'>/// for Arg (i.e. everything except relational rules). The syntax is flexible, but there are</span>
<span class='doccomment'>/// some rules to follow.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// The syntax should be as follows (only properties which you wish to set must be present):</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// 1. Name (arguments with a `long` or that take a value can ommit this if desired),</span>
<span class='doccomment'>/// use `[]` for non-required arguments, or `&lt;&gt;` for required arguments.</span>
<span class='doccomment'>/// 2. Short preceded by a `-`</span>
<span class='doccomment'>/// 3. Long preceded by a `--` (this may be used as the name, if the name is omitted. If the</span>
<span class='doccomment'>/// name is *not* omittied, the name takes precedence)</span>
<span class='doccomment'>/// 4. Value (this can be used as the name, if the name is not manually specified. If the name</span>
<span class='doccomment'>/// is manually specified, it takes precence. If this value is used as the name, it uses the</span>
<span class='doccomment'>/// same `[]` and `&lt;&gt;` requirement rules. If it is *not* used as the name, it still needs to</span>
<span class='doccomment'>/// be surrounded by either `[]` or `&lt;&gt;` but the effect is the same, as the requirement rule</span>
<span class='doccomment'>/// is determined by the name. The value may follow the `short` or `long`. If it</span>
<span class='doccomment'>/// follows the `long`, it may follow either a `=` or ` ` with the same effect, personal</span>
<span class='doccomment'>/// preference only, but may only follow a ` ` after a `short`)</span>
<span class='doccomment'>/// 5. Multiple specifier `...` (for flags or positional arguments the `...` may follow the</span>
<span class='doccomment'>/// name or `short` or `long`)</span>
<span class='doccomment'>/// 6. The help info surrounded by `&#39;`</span>
<span class='doccomment'>/// 7. The index of a positional argument will be the next available index (you don&#39;t need to</span>
<span class='doccomment'>/// specify one)</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// .args(vec![</span>
<span class='doccomment'>/// // A option argument with a long, named &quot;conf&quot; (note: because the name was specified</span>
<span class='doccomment'>/// // the portion after the long can be called anything, only the first name will be displayed</span>
<span class='doccomment'>/// // to the user. Also, requirement is set with the *name*, so the portion after the long could</span>
<span class='doccomment'>/// // be either &lt;&gt; or [] and it wouldn&#39;t matter, so long as it&#39;s one of them. Had the name been</span>
<span class='doccomment'>/// // omitted, the name would have been derived from the portion after the long and those rules</span>
<span class='doccomment'>/// // would have mattered)</span>
<span class='doccomment'>/// Arg::from_usage(&quot;[conf] --config=[c] &#39;a required file for the configuration&#39;&quot;),</span>
<span class='doccomment'>/// // A flag with a short, a long, named &quot;debug&quot;, and accepts multiple values</span>
<span class='doccomment'>/// Arg::from_usage(&quot;-d --debug... &#39;turns on debugging information&quot;),</span>
<span class='doccomment'>/// // A required positional argument named &quot;input&quot;</span>
<span class='doccomment'>/// Arg::from_usage(&quot;&lt;input&gt; &#39;the input file to use&#39;&quot;)</span>
<span class='doccomment'>/// ])</span>
<span class='doccomment'>/// # </span>
<span class='doccomment'>/// # .get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_usage</span>(<span class='ident'>u</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;n</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span><span class='op'>&lt;</span><span class='lifetime'>&#39;n</span>, <span class='lifetime'>&#39;n</span>, <span class='lifetime'>&#39;n</span>, <span class='lifetime'>&#39;b</span>, <span class='lifetime'>&#39;p</span>, <span class='lifetime'>&#39;r</span><span class='op'>&gt;</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>u</span>.<span class='ident'>len</span>() <span class='op'>&gt;</span> <span class='number'>0</span>, <span class='string'>&quot;Arg::from_usage() requires a non-zero-length usage string but none was provided&quot;</span>);
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>name</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'>short</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'>long</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'>help</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'>required</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>takes_value</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>multiple</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>let</span> <span class='ident'>parser</span> <span class='op'>=</span> <span class='ident'>UsageParser</span>::<span class='ident'>with_usage</span>(<span class='ident'>u</span>);
<span class='macro'>for_match</span><span class='macro'>!</span>{ <span class='ident'>parser</span>,
<span class='ident'>UsageToken</span>::<span class='ident'>Name</span>(<span class='ident'>n</span>, <span class='ident'>req</span>) <span class='op'>=&gt;</span> {
<span class='kw'>if</span> <span class='ident'>name</span>.<span class='ident'>is_none</span>() {
<span class='ident'>name</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>n</span>);
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>m</span>) <span class='op'>=</span> <span class='ident'>req</span> {
<span class='ident'>required</span> <span class='op'>=</span> <span class='ident'>m</span>;
}
}
<span class='kw'>if</span> <span class='ident'>short</span>.<span class='ident'>is_some</span>() <span class='op'>||</span> <span class='ident'>long</span>.<span class='ident'>is_some</span>() {
<span class='ident'>takes_value</span> <span class='op'>=</span> <span class='boolval'>true</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'>long</span> {
<span class='kw'>if</span> <span class='ident'>n</span> <span class='op'>!=</span> <span class='ident'>name</span>.<span class='ident'>unwrap</span>() <span class='op'>&amp;&amp;</span> <span class='ident'>name</span>.<span class='ident'>unwrap</span>() <span class='op'>==</span> <span class='ident'>l</span> {
<span class='ident'>name</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>n</span>);
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>m</span>) <span class='op'>=</span> <span class='ident'>req</span> {
<span class='ident'>required</span> <span class='op'>=</span> <span class='ident'>m</span>;
}
}
}
},
<span class='ident'>UsageToken</span>::<span class='ident'>Short</span>(<span class='ident'>s</span>) <span class='op'>=&gt;</span> {
<span class='ident'>short</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>);
},
<span class='ident'>UsageToken</span>::<span class='ident'>Long</span>(<span class='ident'>l</span>) <span class='op'>=&gt;</span> {
<span class='ident'>long</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>l</span>);
<span class='kw'>if</span> <span class='ident'>name</span>.<span class='ident'>is_none</span>() {
<span class='ident'>name</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>l</span>);
}
},
<span class='ident'>UsageToken</span>::<span class='ident'>Help</span>(<span class='ident'>h</span>) <span class='op'>=&gt;</span> {
<span class='ident'>help</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>h</span>);
},
<span class='ident'>UsageToken</span>::<span class='ident'>Multiple</span> <span class='op'>=&gt;</span> {
<span class='ident'>multiple</span> <span class='op'>=</span> <span class='boolval'>true</span>;
}
}
<span class='ident'>Arg</span> {
<span class='ident'>name</span>: <span class='ident'>name</span>.<span class='ident'>unwrap</span>(),
<span class='ident'>short</span>: <span class='ident'>short</span>,
<span class='ident'>long</span>: <span class='ident'>long</span>,
<span class='ident'>help</span>: <span class='ident'>help</span>,
<span class='ident'>required</span>: <span class='ident'>required</span>,
<span class='ident'>takes_value</span>: <span class='ident'>takes_value</span>,
<span class='ident'>multiple</span>: <span class='ident'>multiple</span>,
<span class='ident'>index</span>: <span class='prelude-val'>None</span>,
<span class='ident'>possible_vals</span>: <span class='prelude-val'>None</span>,
<span class='ident'>blacklist</span>: <span class='prelude-val'>None</span>,
<span class='ident'>requires</span>: <span class='prelude-val'>None</span>,
}
}
<span class='doccomment'>/// Sets the short version of the argument without the preceding `-`.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>

File diff suppressed because it is too large Load diff