mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
chore(docs): rebuild documentation
This commit is contained in:
parent
76de2f553a
commit
9f8fced0ab
9 changed files with 39 additions and 61 deletions
|
@ -43,7 +43,7 @@
|
||||||
<section id='main' class="content mod">
|
<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'>
|
<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> <a id="expand-all" href="#">[+]</a>
|
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||||
</span><a id='src-0' href='../src/clap/lib.rs.html#1-339'>[src]</a></span></h1>
|
</span><a id='src-0' href='../src/clap/lib.rs.html#1-341'>[src]</a></span></h1>
|
||||||
<div class='docblock'>
|
<div class='docblock'>
|
||||||
<h1 id="clap" class='section-header'><a
|
<h1 id="clap" class='section-header'><a
|
||||||
href="#clap">clap</a></h1>
|
href="#clap">clap</a></h1>
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<section id='main' class="content struct">
|
<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=''>App</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>App</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||||
</span><a id='src-33' href='../src/clap/app.rs.html#39-66'>[src]</a></span></h1>
|
</span><a id='src-35' href='../src/clap/app.rs.html#39-66'>[src]</a></span></h1>
|
||||||
<pre class='rust struct'>pub struct App<'a, 'v, 'ab, 'u, 'ar> {
|
<pre class='rust struct'>pub struct App<'a, 'v, 'ab, 'u, 'ar> {
|
||||||
// some fields omitted
|
// some fields omitted
|
||||||
}</pre><div class='docblock'><p>Used to create a representation of the program and all possible command line arguments
|
}</pre><div class='docblock'><p>Used to create a representation of the program and all possible command line arguments
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<section id='main' class="content struct">
|
<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'>
|
<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> <a id="expand-all" href="#">[+]</a>
|
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||||
</span><a id='src-8250' href='../src/clap/args/arg.rs.html#21-55'>[src]</a></span></h1>
|
</span><a id='src-8370' href='../src/clap/args/arg.rs.html#21-55'>[src]</a></span></h1>
|
||||||
<pre class='rust struct'>pub struct Arg<'n, 'l, 'h, 'b, 'p, 'r> {
|
<pre class='rust struct'>pub struct Arg<'n, 'l, 'h, 'b, 'p, 'r> {
|
||||||
pub name: &'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
|
pub name: &'n <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><<a href='http://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>>,
|
pub short: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><<a href='http://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>>,
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<section id='main' class="content struct">
|
<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'>
|
<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> <a id="expand-all" href="#">[+]</a>
|
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||||
</span><a id='src-8831' href='../src/clap/args/argmatches.rs.html#62-69'>[src]</a></span></h1>
|
</span><a id='src-8951' href='../src/clap/args/argmatches.rs.html#62-69'>[src]</a></span></h1>
|
||||||
<pre class='rust struct'>pub struct ArgMatches<'a> {
|
<pre class='rust struct'>pub struct ArgMatches<'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><&'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, FlagArg>,
|
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><&'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, FlagArg>,
|
||||||
pub opts: <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><&'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, OptArg>,
|
pub opts: <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><&'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, OptArg>,
|
||||||
|
@ -189,12 +189,12 @@ allow multiple occurrences, it will return <code>1</code> no matter how many tim
|
||||||
_ <span class='op'>=></span> {}, <span class='comment'>// Either no subcommand or one not tested for...</span>
|
_ <span class='op'>=></span> {}, <span class='comment'>// Either no subcommand or one not tested for...</span>
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div><h4 id='method.usage' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.usage' class='fnname'>usage</a>(&self) -> <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>></code></h4>
|
</div><h4 id='method.usage' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.usage' class='fnname'>usage</a>(&self) -> &<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||||||
<div class='docblock'><p>Returns a slice of the default usage for the <em>top level parent App only</em></p>
|
<div class='docblock'><p>Returns a slice of the usage</p>
|
||||||
|
|
||||||
<h1 id="example" class='section-header'><a
|
<h1 id="example" class='section-header'><a
|
||||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{}"</span>,<span class='ident'>app_matches</span>.<span class='ident'>usage</span>().<span class='ident'>unwrap</span>());
|
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{}"</span>,<span class='ident'>app_matches</span>.<span class='ident'>usage</span>());
|
||||||
</pre>
|
</pre>
|
||||||
</div></div></section>
|
</div></div></section>
|
||||||
<section id='search' class="content hidden"></section>
|
<section id='search' class="content hidden"></section>
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<section id='main' class="content struct">
|
<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'>
|
<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> <a id="expand-all" href="#">[+]</a>
|
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||||
</span><a id='src-9325' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
|
</span><a id='src-9442' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
|
||||||
<pre class='rust struct'>pub struct SubCommand<'a> {
|
<pre class='rust struct'>pub struct SubCommand<'a> {
|
||||||
pub name: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a>,
|
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><'a>,
|
pub matches: <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a><'a>,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1285,21 +1285,6 @@
|
||||||
<span id="1243">1243</span>
|
<span id="1243">1243</span>
|
||||||
<span id="1244">1244</span>
|
<span id="1244">1244</span>
|
||||||
<span id="1245">1245</span>
|
<span id="1245">1245</span>
|
||||||
<span id="1246">1246</span>
|
|
||||||
<span id="1247">1247</span>
|
|
||||||
<span id="1248">1248</span>
|
|
||||||
<span id="1249">1249</span>
|
|
||||||
<span id="1250">1250</span>
|
|
||||||
<span id="1251">1251</span>
|
|
||||||
<span id="1252">1252</span>
|
|
||||||
<span id="1253">1253</span>
|
|
||||||
<span id="1254">1254</span>
|
|
||||||
<span id="1255">1255</span>
|
|
||||||
<span id="1256">1256</span>
|
|
||||||
<span id="1257">1257</span>
|
|
||||||
<span id="1258">1258</span>
|
|
||||||
<span id="1259">1259</span>
|
|
||||||
<span id="1260">1260</span>
|
|
||||||
</pre><pre class='rust '>
|
</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'>BTreeMap</span>;
|
||||||
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeSet</span>;
|
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeSet</span>;
|
||||||
|
@ -1730,7 +1715,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='kw'>let</span> <span class='ident'>req_pos</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>values</span>().<span class='ident'>filter_map</span>(<span class='op'>|</span><span class='kw-2'>ref</span> <span class='ident'>x</span><span class='op'>|</span> <span class='kw'>if</span> <span class='ident'>x</span>.<span class='ident'>required</span> <span class='op'>||</span> <span class='ident'>matched_pos_reqs</span>.<span class='ident'>contains</span>(<span class='ident'>x</span>.<span class='ident'>name</span>) {
|
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>req_pos</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>values</span>().<span class='ident'>filter_map</span>(<span class='op'>|</span><span class='kw-2'>ref</span> <span class='ident'>x</span><span class='op'>|</span> <span class='kw'>if</span> <span class='ident'>x</span>.<span class='ident'>required</span> <span class='op'>||</span> <span class='ident'>matched_pos_reqs</span>.<span class='ident'>contains</span>(<span class='ident'>x</span>.<span class='ident'>name</span>) {
|
||||||
<span class='ident'>num_req_pos</span> <span class='op'>+=</span> <span class='number'>1</span>;
|
<span class='ident'>num_req_pos</span> <span class='op'>+=</span> <span class='number'>1</span>;
|
||||||
<span class='kw'>if</span> <span class='ident'>x</span>.<span class='ident'>multiple</span> {
|
<span class='kw'>if</span> <span class='ident'>x</span>.<span class='ident'>multiple</span> {
|
||||||
<span class='prelude-val'>Some</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"<{}>..."</span>, <span class='ident'>x</span>.<span class='ident'>name</span>))
|
<span class='prelude-val'>Some</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"<{}>..."</span>, <span class='ident'>x</span>.<span class='ident'>name</span>))
|
||||||
|
@ -1740,19 +1725,21 @@
|
||||||
} <span class='kw'>else</span> {
|
} <span class='kw'>else</span> {
|
||||||
<span class='prelude-val'>None</span>
|
<span class='prelude-val'>None</span>
|
||||||
} )
|
} )
|
||||||
.<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(), <span class='op'>|</span><span class='ident'>acc</span>, <span class='kw-2'>ref</span> <span class='ident'>name</span><span class='op'>|</span> <span class='ident'>acc</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} "</span>, <span class='ident'>name</span>)[..]);
|
.<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>50</span>), <span class='op'>|</span><span class='ident'>acc</span>, <span class='kw-2'>ref</span> <span class='ident'>name</span><span class='op'>|</span> <span class='ident'>acc</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} "</span>, <span class='ident'>name</span>)[..]);
|
||||||
|
<span class='ident'>req_pos</span>.<span class='ident'>shrink_to_fit</span>();
|
||||||
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>num_req_opts</span> <span class='op'>=</span> <span class='number'>0</span>;
|
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>num_req_opts</span> <span class='op'>=</span> <span class='number'>0</span>;
|
||||||
<span class='kw'>let</span> <span class='ident'>req_opts</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>values</span>().<span class='ident'>filter_map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='kw'>if</span> <span class='ident'>x</span>.<span class='ident'>required</span> <span class='op'>||</span> <span class='self'>self</span>.<span class='ident'>matched_reqs</span>.<span class='ident'>contains</span>(<span class='ident'>x</span>.<span class='ident'>name</span>) {
|
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>req_opts</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>values</span>().<span class='ident'>filter_map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='kw'>if</span> <span class='ident'>x</span>.<span class='ident'>required</span> <span class='op'>||</span> <span class='self'>self</span>.<span class='ident'>matched_reqs</span>.<span class='ident'>contains</span>(<span class='ident'>x</span>.<span class='ident'>name</span>) {
|
||||||
<span class='ident'>num_req_opts</span> <span class='op'>+=</span> <span class='number'>1</span>;
|
<span class='ident'>num_req_opts</span> <span class='op'>+=</span> <span class='number'>1</span>;
|
||||||
<span class='prelude-val'>Some</span>(<span class='ident'>x</span>)
|
<span class='prelude-val'>Some</span>(<span class='ident'>x</span>)
|
||||||
}<span class='kw'>else</span> {
|
}<span class='kw'>else</span> {
|
||||||
<span class='prelude-val'>None</span>
|
<span class='prelude-val'>None</span>
|
||||||
})
|
})
|
||||||
.<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(), <span class='op'>|</span><span class='ident'>acc</span>, <span class='kw-2'>ref</span> <span class='ident'>o</span><span class='op'>|</span> <span class='ident'>acc</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"-{}{} "</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'>o</span>.<span class='ident'>long</span> {
|
.<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>50</span>), <span class='op'>|</span><span class='ident'>acc</span>, <span class='kw-2'>ref</span> <span class='ident'>o</span><span class='op'>|</span> <span class='ident'>acc</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"-{}{} "</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'>o</span>.<span class='ident'>long</span> {
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"-{}="</span>, <span class='ident'>l</span>)
|
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"-{}="</span>, <span class='ident'>l</span>)
|
||||||
} <span class='kw'>else</span> {
|
} <span class='kw'>else</span> {
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} "</span>,<span class='ident'>o</span>.<span class='ident'>short</span>.<span class='ident'>unwrap</span>())
|
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} "</span>,<span class='ident'>o</span>.<span class='ident'>short</span>.<span class='ident'>unwrap</span>())
|
||||||
},<span class='ident'>o</span>.<span class='ident'>name</span>));
|
},<span class='ident'>o</span>.<span class='ident'>name</span>));
|
||||||
|
<span class='ident'>req_opts</span>.<span class='ident'>shrink_to_fit</span>();
|
||||||
|
|
||||||
<span class='comment'>// usage.push_str(tab);</span>
|
<span class='comment'>// usage.push_str(tab);</span>
|
||||||
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>bin_name</span>.<span class='ident'>clone</span>().<span class='ident'>unwrap_or</span>(<span class='self'>self</span>.<span class='ident'>name</span>.<span class='ident'>clone</span>())[..]);
|
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>bin_name</span>.<span class='ident'>clone</span>().<span class='ident'>unwrap_or</span>(<span class='self'>self</span>.<span class='ident'>name</span>.<span class='ident'>clone</span>())[..]);
|
||||||
|
@ -1763,22 +1750,22 @@
|
||||||
<span class='kw'>if</span> <span class='ident'>opts</span> {
|
<span class='kw'>if</span> <span class='ident'>opts</span> {
|
||||||
<span class='macro'>write</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>usage</span>,<span class='string'>" {}"</span>,
|
<span class='macro'>write</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>usage</span>,<span class='string'>" {}"</span>,
|
||||||
<span class='kw'>if</span> <span class='ident'>num_req_opts</span> <span class='op'>!=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>len</span>() <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>req_opts</span>.<span class='ident'>is_empty</span>() {
|
<span class='kw'>if</span> <span class='ident'>num_req_opts</span> <span class='op'>!=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>len</span>() <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>req_opts</span>.<span class='ident'>is_empty</span>() {
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" [OPTIONS] {}"</span>, <span class='kw-2'>&</span><span class='ident'>req_opts</span>[..])
|
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"[OPTIONS] {}"</span>, <span class='kw-2'>&</span><span class='ident'>req_opts</span>[..])
|
||||||
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>req_opts</span>.<span class='ident'>is_empty</span>() {
|
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>req_opts</span>.<span class='ident'>is_empty</span>() {
|
||||||
<span class='string'>" [OPTIONS]"</span>.<span class='ident'>to_owned</span>()
|
<span class='string'>"[OPTIONS]"</span>.<span class='ident'>to_owned</span>()
|
||||||
} <span class='kw'>else</span> {
|
} <span class='kw'>else</span> {
|
||||||
<span class='ident'>req_opts</span>
|
<span class='ident'>req_opts</span>
|
||||||
});
|
}).<span class='ident'>unwrap_or_else</span>(<span class='op'>|</span><span class='ident'>e</span><span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"internal error: {}"</span>, <span class='ident'>e</span>),<span class='boolval'>false</span>,<span class='boolval'>true</span>));
|
||||||
}
|
}
|
||||||
<span class='kw'>if</span> <span class='ident'>pos</span> {
|
<span class='kw'>if</span> <span class='ident'>pos</span> {
|
||||||
<span class='macro'>write</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>usage</span>, <span class='string'>" {}"</span>,
|
<span class='macro'>write</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>usage</span>, <span class='string'>" {}"</span>,
|
||||||
<span class='kw'>if</span> <span class='ident'>num_req_pos</span> <span class='op'>!=</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>len</span>() <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>req_pos</span>.<span class='ident'>is_empty</span>() {
|
<span class='kw'>if</span> <span class='ident'>num_req_pos</span> <span class='op'>!=</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>len</span>() <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>req_pos</span>.<span class='ident'>is_empty</span>() {
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" [POSITIONAL] {}"</span>, <span class='kw-2'>&</span><span class='ident'>req_pos</span>[..])
|
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"[POSITIONAL] {}"</span>, <span class='kw-2'>&</span><span class='ident'>req_pos</span>[..])
|
||||||
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>req_pos</span>.<span class='ident'>is_empty</span>() {
|
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>req_pos</span>.<span class='ident'>is_empty</span>() {
|
||||||
<span class='string'>" [POSITIONAL]"</span>.<span class='ident'>to_owned</span>()
|
<span class='string'>"[POSITIONAL]"</span>.<span class='ident'>to_owned</span>()
|
||||||
} <span class='kw'>else</span> {
|
} <span class='kw'>else</span> {
|
||||||
<span class='ident'>req_pos</span>
|
<span class='ident'>req_pos</span>
|
||||||
} );
|
} ).<span class='ident'>unwrap_or_else</span>(<span class='op'>|</span><span class='ident'>e</span><span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"internal error: {}"</span>, <span class='ident'>e</span>),<span class='boolval'>false</span>,<span class='boolval'>true</span>));
|
||||||
}
|
}
|
||||||
<span class='kw'>if</span> <span class='ident'>subcmds</span> {
|
<span class='kw'>if</span> <span class='ident'>subcmds</span> {
|
||||||
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='string'>" [SUBCOMMANDS]"</span>);
|
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='string'>" [SUBCOMMANDS]"</span>);
|
||||||
|
@ -1892,16 +1879,7 @@
|
||||||
<span class='comment'>// 7 is '--=' (3) + tab (4)</span>
|
<span class='comment'>// 7 is '--=' (3) + tab (4)</span>
|
||||||
<span class='self'>self</span>.<span class='ident'>get_spaces</span>((<span class='ident'>longest_opt</span> <span class='op'>+</span> <span class='number'>6</span>) <span class='op'>-</span> (<span class='ident'>v</span>.<span class='ident'>name</span>.<span class='ident'>len</span>() <span class='op'>+</span> <span class='ident'>mult</span>))
|
<span class='self'>self</span>.<span class='ident'>get_spaces</span>((<span class='ident'>longest_opt</span> <span class='op'>+</span> <span class='number'>6</span>) <span class='op'>-</span> (<span class='ident'>v</span>.<span class='ident'>name</span>.<span class='ident'>len</span>() <span class='op'>+</span> <span class='ident'>mult</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='macro'>get_help</span><span class='macro'>!</span>(<span class='ident'>v</span>) );
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}{}"</span>, <span class='ident'>h</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'>pv</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>possible_vals</span> {
|
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" [values:{}]"</span>, <span class='ident'>pv</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(), <span class='op'>|</span><span class='ident'>acc</span>, <span class='ident'>name</span><span class='op'>|</span> <span class='ident'>acc</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>,<span class='ident'>name</span>)[..] ))
|
|
||||||
}<span class='kw'>else</span>{
|
|
||||||
<span class='string'>""</span>.<span class='ident'>to_owned</span>()
|
|
||||||
})
|
|
||||||
} <span class='kw'>else</span> {
|
|
||||||
<span class='ident'>tab</span>.<span class='ident'>to_owned</span>()
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<span class='kw'>if</span> <span class='ident'>pos</span> {
|
<span class='kw'>if</span> <span class='ident'>pos</span> {
|
||||||
|
@ -1912,15 +1890,7 @@
|
||||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{}{}{}{}"</span>,<span class='ident'>tab</span>,
|
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{}{}{}{}"</span>,<span class='ident'>tab</span>,
|
||||||
<span class='kw'>if</span> <span class='ident'>v</span>.<span class='ident'>multiple</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}..."</span>,<span class='ident'>v</span>.<span class='ident'>name</span>)} <span class='kw'>else</span> {<span class='ident'>v</span>.<span class='ident'>name</span>.<span class='ident'>to_owned</span>()},
|
<span class='kw'>if</span> <span class='ident'>v</span>.<span class='ident'>multiple</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}..."</span>,<span class='ident'>v</span>.<span class='ident'>name</span>)} <span class='kw'>else</span> {<span class='ident'>v</span>.<span class='ident'>name</span>.<span class='ident'>to_owned</span>()},
|
||||||
<span class='self'>self</span>.<span class='ident'>get_spaces</span>((<span class='ident'>longest_pos</span> <span class='op'>+</span> <span class='number'>4</span>) <span class='op'>-</span> (<span class='ident'>v</span>.<span class='ident'>name</span>.<span class='ident'>len</span>() <span class='op'>+</span> <span class='ident'>mult</span>)),
|
<span class='self'>self</span>.<span class='ident'>get_spaces</span>((<span class='ident'>longest_pos</span> <span class='op'>+</span> <span class='number'>4</span>) <span class='op'>-</span> (<span class='ident'>v</span>.<span class='ident'>name</span>.<span class='ident'>len</span>() <span class='op'>+</span> <span class='ident'>mult</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='macro'>get_help</span><span class='macro'>!</span>(<span class='ident'>v</span>));
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}{}"</span>,
|
|
||||||
<span class='ident'>h</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'>pv</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>possible_vals</span> {
|
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" [values:{}]"</span>, <span class='ident'>pv</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(), <span class='op'>|</span><span class='ident'>acc</span>, <span class='ident'>name</span><span class='op'>|</span> <span class='ident'>acc</span> <span class='op'>+</span> <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>" {}"</span>,<span class='ident'>name</span>)[..] ))
|
|
||||||
}<span class='kw'>else</span>{<span class='string'>""</span>.<span class='ident'>to_owned</span>()})
|
|
||||||
} <span class='kw'>else</span> {
|
|
||||||
<span class='ident'>tab</span>.<span class='ident'>to_owned</span>()
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<span class='kw'>if</span> <span class='ident'>subcmds</span> {
|
<span class='kw'>if</span> <span class='ident'>subcmds</span> {
|
||||||
|
@ -2009,7 +1979,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<span class='ident'>matches</span>.<span class='ident'>usage</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>create_usage</span>());
|
|
||||||
<span class='self'>self</span>.<span class='ident'>get_matches_from</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>matches</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>it</span> );
|
<span class='self'>self</span>.<span class='ident'>get_matches_from</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>matches</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>it</span> );
|
||||||
|
|
||||||
<span class='ident'>matches</span>
|
<span class='ident'>matches</span>
|
||||||
|
@ -2114,7 +2083,7 @@
|
||||||
|
|
||||||
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</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='self'>self</span>.<span class='ident'>report_error</span>(
|
<span class='self'>self</span>.<span class='ident'>report_error</span>(
|
||||||
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"Found positional argument {}, but {} doesn't accept any"</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'>"Argument \"{}\" isn't a valid option for {}"</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>bin_name</span>.<span class='ident'>clone</span>().<span class='ident'>unwrap_or</span>(<span class='self'>self</span>.<span class='ident'>name</span>.<span class='ident'>clone</span>())),
|
||||||
<span class='boolval'>true</span>, <span class='boolval'>true</span>);
|
<span class='boolval'>true</span>, <span class='boolval'>true</span>);
|
||||||
}
|
}
|
||||||
<span class='comment'>// If we find that an argument requires a positiona, we need to update all the</span>
|
<span class='comment'>// If we find that an argument requires a positiona, we need to update all the</span>
|
||||||
|
@ -2182,7 +2151,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} <span class='kw'>else</span> {
|
} <span class='kw'>else</span> {
|
||||||
<span class='self'>self</span>.<span class='ident'>report_error</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"Positional argument \"{}\" was found, but {} wasn't expecting any"</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>name</span>), <span class='boolval'>true</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'>"Argument \"{}\" isn't a valid argument for {}"</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>bin_name</span>.<span class='ident'>clone</span>().<span class='ident'>unwrap_or</span>(<span class='self'>self</span>.<span class='ident'>name</span>.<span class='ident'>clone</span>())), <span class='boolval'>true</span>, <span class='boolval'>true</span>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2202,6 +2171,7 @@
|
||||||
<span class='boolval'>true</span>, <span class='boolval'>true</span>);
|
<span class='boolval'>true</span>, <span class='boolval'>true</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<span class='ident'>matches</span>.<span class='ident'>usage</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>create_usage</span>());
|
||||||
|
|
||||||
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>sc_name</span>) <span class='op'>=</span> <span class='ident'>subcmd_name</span> {
|
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>sc_name</span>) <span class='op'>=</span> <span class='ident'>subcmd_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='kw-2'>mut</span> <span class='ident'>sc</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>subcommands</span>.<span class='ident'>get_mut</span>(<span class='kw-2'>&</span><span class='ident'>sc_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='kw-2'>mut</span> <span class='ident'>sc</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>subcommands</span>.<span class='ident'>get_mut</span>(<span class='kw-2'>&</span><span class='ident'>sc_name</span>) {
|
||||||
|
|
|
@ -325,6 +325,8 @@
|
||||||
<span id="283">283</span>
|
<span id="283">283</span>
|
||||||
<span id="284">284</span>
|
<span id="284">284</span>
|
||||||
<span id="285">285</span>
|
<span id="285">285</span>
|
||||||
|
<span id="286">286</span>
|
||||||
|
<span id="287">287</span>
|
||||||
</pre><pre class='rust '>
|
</pre><pre class='rust '>
|
||||||
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
|
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
|
||||||
|
|
||||||
|
@ -594,7 +596,7 @@
|
||||||
(<span class='string'>""</span>, <span class='prelude-val'>None</span>)
|
(<span class='string'>""</span>, <span class='prelude-val'>None</span>)
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='doccomment'>/// Returns a slice of the default usage for the *top level parent App only*</span>
|
<span class='doccomment'>/// Returns a slice of the usage</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// # Example</span>
|
<span class='doccomment'>/// # Example</span>
|
||||||
|
@ -602,13 +604,15 @@
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</span>
|
||||||
<span class='doccomment'>/// # let app_matches = App::new("myapp").subcommand(SubCommand::new("test")).get_matches();</span>
|
<span class='doccomment'>/// # let app_matches = App::new("myapp").subcommand(SubCommand::new("test")).get_matches();</span>
|
||||||
<span class='doccomment'>/// println!("{}",app_matches.usage().unwrap());</span>
|
<span class='doccomment'>/// println!("{}",app_matches.usage());</span>
|
||||||
<span class='doccomment'>/// ```</span>
|
<span class='doccomment'>/// ```</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>usage</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span> {
|
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>usage</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</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'>u</span> ) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>usage</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'>u</span> ) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>usage</span> {
|
||||||
<span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>&</span><span class='ident'>u</span>[..]);
|
<span class='kw'>return</span> <span class='kw-2'>&</span><span class='ident'>u</span>[..];
|
||||||
}
|
}
|
||||||
<span class='prelude-val'>None</span>
|
|
||||||
|
<span class='comment'>// Should be un-reachable</span>
|
||||||
|
<span class='string'>""</span>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -379,6 +379,8 @@
|
||||||
<span id="337">337</span>
|
<span id="337">337</span>
|
||||||
<span id="338">338</span>
|
<span id="338">338</span>
|
||||||
<span id="339">339</span>
|
<span id="339">339</span>
|
||||||
|
<span id="340">340</span>
|
||||||
|
<span id="341">341</span>
|
||||||
</pre><pre class='rust '>
|
</pre><pre class='rust '>
|
||||||
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>crate_type</span><span class='op'>=</span> <span class='string'>"lib"</span>]</span>
|
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>crate_type</span><span class='op'>=</span> <span class='string'>"lib"</span>]</span>
|
||||||
|
|
||||||
|
@ -613,6 +615,8 @@
|
||||||
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>args</span>::{<span class='ident'>Arg</span>, <span class='ident'>SubCommand</span>, <span class='ident'>ArgMatches</span>};
|
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>args</span>::{<span class='ident'>Arg</span>, <span class='ident'>SubCommand</span>, <span class='ident'>ArgMatches</span>};
|
||||||
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>app</span>::<span class='ident'>App</span>;
|
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>app</span>::<span class='ident'>App</span>;
|
||||||
|
|
||||||
|
<span class='attribute'>#[<span class='ident'>macro_use</span>]</span>
|
||||||
|
<span class='kw'>mod</span> <span class='ident'>macros</span>;
|
||||||
<span class='kw'>mod</span> <span class='ident'>app</span>;
|
<span class='kw'>mod</span> <span class='ident'>app</span>;
|
||||||
<span class='kw'>mod</span> <span class='ident'>args</span>;
|
<span class='kw'>mod</span> <span class='ident'>args</span>;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue