Rebuilt docs and inc'ed version from recent commits

This commit is contained in:
Kevin K 2015-03-18 15:14:30 -04:00
parent e711d91998
commit d9244b6879
28 changed files with 337 additions and 191 deletions

View file

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

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../clap/struct.Arg.html">
</head>
<body>
<p>Redirecting to <a href="../../clap/struct.Arg.html">../../clap/struct.Arg.html</a>...</p>
<script>location.replace("../../clap/struct.Arg.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../clap/struct.ArgMatches.html">
</head>
<body>
<p>Redirecting to <a href="../../clap/struct.ArgMatches.html">../../clap/struct.ArgMatches.html</a>...</p>
<script>location.replace("../../clap/struct.ArgMatches.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../clap/struct.Arg.html">
</head>
<body>
<p>Redirecting to <a href="../../../clap/struct.Arg.html">../../../clap/struct.Arg.html</a>...</p>
<script>location.replace("../../../clap/struct.Arg.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../clap/struct.ArgMatches.html">
</head>
<body>
<p>Redirecting to <a href="../../../clap/struct.ArgMatches.html">../../../clap/struct.ArgMatches.html</a>...</p>
<script>location.replace("../../../clap/struct.ArgMatches.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1 @@
initSidebarItems({});

View file

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../clap/struct.SubCommand.html">
</head>
<body>
<p>Redirecting to <a href="../../../clap/struct.SubCommand.html">../../../clap/struct.SubCommand.html</a>...</p>
<script>location.replace("../../../clap/struct.SubCommand.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -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>&nbsp;<a id="expand-all" href="#">[+]</a> <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-155'>[src]</a></span></h1> </span><a id='src-0' href='../src/clap/lib.rs.html#1-150'>[src]</a></span></h1>
<div class='docblock'><p>A simply library for parsing command line arguments when writing <div class='docblock'><p>A simply library for parsing command line arguments when writing
command line and console applications.</p> command line and console applications.</p>
@ -66,22 +66,22 @@ determine the functioning of your program.</p>
.<span class='ident'>author</span>(<span class='string'>&quot;Kevin K. &lt;kbknapp@gmail.com&gt;&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'>about</span>(<span class='string'>&quot;Does awesome things&quot;</span>)
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config&quot;</span>) .<span class='ident'>arg</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'>short</span>(<span class='string'>&quot;c&quot;</span>)
.<span class='ident'>long</span>(<span class='string'>&quot;config&quot;</span>) .<span class='ident'>long</span>(<span class='string'>&quot;config&quot;</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Sets a custom config file&quot;</span>) .<span class='ident'>help</span>(<span class='string'>&quot;Sets a custom config file&quot;</span>)
.<span class='ident'>takes_value</span>(<span class='boolval'>true</span>)) .<span class='ident'>takes_value</span>(<span class='boolval'>true</span>))
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;output&quot;</span>) .<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;output&quot;</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Sets an optional output file&quot;</span>) .<span class='ident'>help</span>(<span class='string'>&quot;Sets an optional output file&quot;</span>)
.<span class='ident'>index</span>(<span class='number'>1</span>)) .<span class='ident'>index</span>(<span class='number'>1</span>))
.<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'>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'>short</span>(<span class='string'>&quot;d&quot;</span>)
.<span class='ident'>multiple</span>(<span class='boolval'>true</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;Turn debugging information on&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'>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;Has test sub functionality&quot;</span>) .<span class='ident'>about</span>(<span class='string'>&quot;Has test sub functionality&quot;</span>)
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;verbose&quot;</span>) .<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;verbose&quot;</span>)
.<span class='ident'>short</span>(<span class='string'>&quot;v&quot;</span>) .<span class='ident'>short</span>(<span class='string'>&quot;v&quot;</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Display verbose information&quot;</span>))) .<span class='ident'>help</span>(<span class='string'>&quot;Display verbose information&quot;</span>)))
.<span class='ident'>get_matches</span>(); .<span class='ident'>get_matches</span>();
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>o</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;output&quot;</span>) { <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>o</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;output&quot;</span>) {

View file

@ -43,12 +43,8 @@
<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>&nbsp;<a id="expand-all" href="#">[+]</a> <a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-23' href='../src/clap/app.rs.html#40-67'>[src]</a></span></h1> </span><a id='src-25' href='../src/clap/app.rs.html#35-61'>[src]</a></span></h1>
<pre class='rust struct'>pub struct App { <pre class='rust struct'>pub struct App {
pub name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
pub author: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;,
pub version: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;,
pub about: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;,
// 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
for parsing at runtime.</p> for parsing at runtime.</p>
@ -70,12 +66,7 @@ help and versioning information.</p>
<span class='comment'>// Your pogram logic starts here...</span> <span class='comment'>// Your pogram logic starts here...</span>
</pre> </pre>
</div><h2 class='fields'>Fields</h2> </div><h2 id='methods'>Methods</h2><h3 class='impl'><a class='stability Unmarked' title='No stability level'></a><code>impl <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h3><div class='impl-items'><h4 id='method.new' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.new' class='fnname'>new</a>(n: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<table><tr><td id='structfield.name'><a class='stability Unmarked' title='No stability level'></a><code>name</code></td><td><div class='docblock'><p>The name displayed to the user when showing version and help/usage information</p>
</div></td></tr><tr><td id='structfield.author'><a class='stability Unmarked' title='No stability level'></a><code>author</code></td><td><div class='docblock'><p>A string of author(s) if desired. Displayed when showing help/usage information</p>
</div></td></tr><tr><td id='structfield.version'><a class='stability Unmarked' title='No stability level'></a><code>version</code></td><td><div class='docblock'><p>The version displayed to the user</p>
</div></td></tr><tr><td id='structfield.about'><a class='stability Unmarked' title='No stability level'></a><code>about</code></td><td><div class='docblock'><p>A brief explaination of the program that gets displayed to the user when shown help/usage information</p>
</div></td></tr></table><h2 id='methods'>Methods</h2><h3 class='impl'><a class='stability Unmarked' title='No stability level'></a><code>impl <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h3><div class='impl-items'><h4 id='method.new' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.new' class='fnname'>new</a>(n: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Creates a new instance of an application requiring a name (such as the binary). Will be displayed <div class='docblock'><p>Creates a new instance of an application requiring a name (such as the binary). Will be displayed
to the user when they print version or help and usage information.</p> to the user when they print version or help and usage information.</p>

View file

@ -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>&nbsp;<a id="expand-all" href="#">[+]</a> <a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-5343' href='../src/clap/arg.rs.html#21-53'>[src]</a></span></h1> </span><a id='src-5097' href='../src/clap/args/arg.rs.html#21-53'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Arg { <pre class='rust struct'>pub struct Arg {
pub name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, pub name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
pub short: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a href='http://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>&gt;, pub short: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a href='http://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>&gt;,

View file

@ -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>&nbsp;<a id="expand-all" href="#">[+]</a> <a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-5068' href='../src/clap/argmatches.rs.html#60-66'>[src]</a></span></h1> </span><a id='src-5687' href='../src/clap/args/argmatches.rs.html#59-65'>[src]</a></span></h1>
<pre class='rust struct'>pub struct ArgMatches { <pre class='rust struct'>pub struct ArgMatches {
pub matches_of: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, pub matches_of: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
pub flags: <a class='struct' href='http://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html' title='std::collections::hash::map::HashMap'>HashMap</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, FlagArg&gt;, pub flags: <a class='struct' href='http://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html' title='std::collections::hash::map::HashMap'>HashMap</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, FlagArg&gt;,

View file

@ -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>&nbsp;<a id="expand-all" href="#">[+]</a> <a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-6042' href='../src/clap/subcommand.rs.html#23-26'>[src]</a></span></h1> </span><a id='src-6071' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
<pre class='rust struct'>pub struct SubCommand { <pre class='rust struct'>pub struct SubCommand {
pub name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, pub name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
pub matches: <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>, pub matches: <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>,

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../clap/struct.SubCommand.html">
</head>
<body>
<p>Redirecting to <a href="../../clap/struct.SubCommand.html">../../clap/struct.SubCommand.html</a>...</p>
<script>location.replace("../../clap/struct.SubCommand.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -209,6 +209,33 @@
break; break;
} }
} }
// searching by type
} else if (val.search("->") > -1) {
var trimmer = function (s) { return s.trim(); };
var parts = val.split("->").map(trimmer);
var input = parts[0];
// sort inputs so that order does not matter
var inputs = input.split(",").map(trimmer).sort();
var output = parts[1];
for (var i = 0; i < nSearchWords; ++i) {
var type = searchIndex[i].type;
if (!type) {
continue;
}
// sort index inputs so that order does not matter
var typeInputs = type.inputs.map(function (input) {
return input.name;
}).sort();
// allow searching for void (no output) functions as well
var typeOutput = type.output ? type.output.name : "";
if (inputs.toString() === typeInputs.toString() &&
output == typeOutput) {
results.push({id: i, index: -1, dontValidate: true});
}
}
} else { } else {
// gather matching search results up to a certain maximum // gather matching search results up to a certain maximum
val = val.replace(/\_/g, ""); val = val.replace(/\_/g, "");
@ -329,6 +356,11 @@
path = result.item.path.toLowerCase(), path = result.item.path.toLowerCase(),
parent = result.item.parent; parent = result.item.parent;
// this validation does not make sense when searching by types
if (result.dontValidate) {
continue;
}
var valid = validateResult(name, path, split, parent); var valid = validateResult(name, path, split, parent);
if (!valid) { if (!valid) {
result.id = -1; result.id = -1;
@ -573,7 +605,8 @@
// (String) name, // (String) name,
// (String) full path or empty string for previous path, // (String) full path or empty string for previous path,
// (String) description, // (String) description,
// (optional Number) the parent path index to `paths`] // (Number | null) the parent path index to `paths`]
// (Object | null) the type of the function (if any)
var items = rawSearchIndex[crate].items; var items = rawSearchIndex[crate].items;
// an array of [(Number) item type, // an array of [(Number) item type,
// (String) name] // (String) name]
@ -598,7 +631,7 @@
var rawRow = items[i]; var rawRow = items[i];
var row = {crate: crate, ty: rawRow[0], name: rawRow[1], var row = {crate: crate, ty: rawRow[0], name: rawRow[1],
path: rawRow[2] || lastPath, desc: rawRow[3], path: rawRow[2] || lastPath, desc: rawRow[3],
parent: paths[rawRow[4]]}; parent: paths[rawRow[4]], type: rawRow[5]};
searchIndex.push(row); searchIndex.push(row);
if (typeof row.name === "string") { if (typeof row.name === "string") {
var word = row.name.toLowerCase(); var word = row.name.toLowerCase();

File diff suppressed because one or more lines are too long

View file

@ -907,6 +907,14 @@
<span id="865">865</span> <span id="865">865</span>
<span id="866">866</span> <span id="866">866</span>
<span id="867">867</span> <span id="867">867</span>
<span id="868">868</span>
<span id="869">869</span>
<span id="870">870</span>
<span id="871">871</span>
<span id="872">872</span>
<span id="873">873</span>
<span id="874">874</span>
<span id="875">875</span>
</pre><pre class='rust '> </pre><pre class='rust '>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libc</span>; <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libc</span>;
@ -917,12 +925,7 @@
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>path</span>::<span class='ident'>Path</span>; <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>path</span>::<span class='ident'>Path</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>vec</span>::<span class='ident'>IntoIter</span>; <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>vec</span>::<span class='ident'>IntoIter</span>;
<span class='kw'>use</span> <span class='ident'>argmatches</span>::<span class='ident'>ArgMatches</span>; <span class='kw'>use</span> <span class='ident'>args</span>::{ <span class='ident'>ArgMatches</span>, <span class='ident'>Arg</span>, <span class='ident'>OptArg</span>, <span class='ident'>FlagArg</span>, <span class='ident'>PosArg</span>, <span class='ident'>SubCommand</span> };
<span class='kw'>use</span> <span class='ident'>Arg</span>;
<span class='kw'>use</span> <span class='ident'>args</span>::<span class='ident'>OptArg</span>;
<span class='kw'>use</span> <span class='ident'>args</span>::<span class='ident'>FlagArg</span>;
<span class='kw'>use</span> <span class='ident'>args</span>::<span class='ident'>PosArg</span>;
<span class='kw'>use</span> <span class='ident'>subcommand</span>::<span class='ident'>SubCommand</span>;
<span class='doccomment'>/// Used to create a representation of the program and all possible command line arguments</span> <span class='doccomment'>/// Used to create a representation of the program and all possible command line arguments</span>
<span class='doccomment'>/// for parsing at runtime.</span> <span class='doccomment'>/// for parsing at runtime.</span>
@ -948,19 +951,18 @@
<span class='doccomment'>/// // Your pogram logic starts here...</span> <span class='doccomment'>/// // Your pogram logic starts here...</span>
<span class='doccomment'>/// ```</span> <span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>App</span> { <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>App</span> {
<span class='doccomment'>/// The name displayed to the user when showing version and help/usage information</span> <span class='comment'>// The name displayed to the user when showing version and help/usage information</span>
<span class='kw'>pub</span> <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>,
<span class='doccomment'>/// A string of author(s) if desired. Displayed when showing help/usage information</span> <span class='comment'>// A string of author(s) if desired. Displayed when showing help/usage information</span>
<span class='kw'>pub</span> <span class='ident'>author</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>, <span class='ident'>author</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>,
<span class='doccomment'>/// The version displayed to the user</span> <span class='comment'>// The version displayed to the user</span>
<span class='kw'>pub</span> <span class='ident'>version</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>, <span class='ident'>version</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>,
<span class='doccomment'>/// A brief explaination of the program that gets displayed to the user when shown help/usage information</span> <span class='comment'>// A brief explaination of the program that gets displayed to the user when shown help/usage information</span>
<span class='kw'>pub</span> <span class='ident'>about</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>, <span class='ident'>about</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>,
<span class='ident'>flags</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>FlagArg</span><span class='op'>&gt;</span>, <span class='ident'>flags</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>FlagArg</span><span class='op'>&gt;</span>,
<span class='ident'>opts</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>OptArg</span><span class='op'>&gt;</span>, <span class='ident'>opts</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>OptArg</span><span class='op'>&gt;</span>,
<span class='ident'>positionals_idx</span>: <span class='ident'>BTreeMap</span><span class='op'>&lt;</span><span class='ident'>u8</span>, <span class='ident'>PosArg</span><span class='op'>&gt;</span>, <span class='ident'>positionals_idx</span>: <span class='ident'>BTreeMap</span><span class='op'>&lt;</span><span class='ident'>u8</span>, <span class='ident'>PosArg</span><span class='op'>&gt;</span>,
<span class='ident'>subcommands</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>Box</span><span class='op'>&lt;</span><span class='ident'>App</span><span class='op'>&gt;&gt;</span>, <span class='ident'>subcommands</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>, <span class='ident'>Box</span><span class='op'>&lt;</span><span class='ident'>App</span><span class='op'>&gt;&gt;</span>,
<span class='comment'>// positionals_name: HashMap&lt;&amp;&#39;static str, PosArg&gt;,</span>
<span class='ident'>needs_long_help</span>: <span class='ident'>bool</span>, <span class='ident'>needs_long_help</span>: <span class='ident'>bool</span>,
<span class='ident'>needs_long_version</span>: <span class='ident'>bool</span>, <span class='ident'>needs_long_version</span>: <span class='ident'>bool</span>,
<span class='ident'>needs_short_help</span>: <span class='ident'>bool</span>, <span class='ident'>needs_short_help</span>: <span class='ident'>bool</span>,
@ -1257,13 +1259,13 @@
<span class='kw'>let</span> <span class='ident'>flags</span> <span class='op'>=</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>is_empty</span>(); <span class='kw'>let</span> <span class='ident'>flags</span> <span class='op'>=</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>is_empty</span>();
<span class='kw'>let</span> <span class='ident'>pos</span> <span class='op'>=</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>is_empty</span>(); <span class='kw'>let</span> <span class='ident'>pos</span> <span class='op'>=</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>is_empty</span>();
<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='prelude-val'>Some</span>(<span class='ident'>x</span>.<span class='ident'>name</span>) } <span class='kw'>else</span> {<span class='prelude-val'>None</span>}) <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='prelude-val'>Some</span>(<span class='ident'>x</span>.<span class='ident'>name</span>) } <span class='kw'>else</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'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;&lt;{}&gt; &quot;</span>, <span class='ident'>name</span>.<span class='ident'>to_uppercase</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'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;&lt;{}&gt; &quot;</span>, <span class='ident'>name</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</span>(<span class='op'>|</span><span class='kw-2'>ref</span> <span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span>.<span class='ident'>required</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</span>(<span class='op'>|</span><span class='kw-2'>ref</span> <span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span>.<span class='ident'>required</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'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{}{} &quot;</span>,<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>o</span>.<span class='ident'>short</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'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{}{} &quot;</span>,<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>o</span>.<span class='ident'>short</span> {
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{} &quot;</span>, <span class='ident'>s</span>) <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{} &quot;</span>, <span class='ident'>s</span>)
} <span class='kw'>else</span> { } <span class='kw'>else</span> {
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;--{}=&quot;</span>,<span class='ident'>o</span>.<span class='ident'>long</span>.<span class='ident'>unwrap</span>()) <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;--{}=&quot;</span>,<span class='ident'>o</span>.<span class='ident'>long</span>.<span class='ident'>unwrap</span>())
},<span class='ident'>o</span>.<span class='ident'>name</span>.<span class='ident'>to_uppercase</span>())); },<span class='ident'>o</span>.<span class='ident'>name</span>));
<span class='kw'>let</span> <span class='ident'>opts</span> <span class='op'>=</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>is_empty</span>(); <span class='kw'>let</span> <span class='ident'>opts</span> <span class='op'>=</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>is_empty</span>();
<span class='kw'>let</span> <span class='ident'>subcmds</span> <span class='op'>=</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>subcommands</span>.<span class='ident'>is_empty</span>(); <span class='kw'>let</span> <span class='ident'>subcmds</span> <span class='op'>=</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>subcommands</span>.<span class='ident'>is_empty</span>();
@ -1319,7 +1321,7 @@
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;\t{}{}{}\t{}&quot;</span>, <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;\t{}{}{}\t{}&quot;</span>,
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>short</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{} &quot;</span>,<span class='ident'>s</span>)}<span class='kw'>else</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)}, <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>short</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{} &quot;</span>,<span class='ident'>s</span>)}<span class='kw'>else</span>{<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)},
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>l</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>long</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;,--{}=&quot;</span>,<span class='ident'>l</span>)}<span class='kw'>else</span> {<span class='ident'>needs_tab</span> <span class='op'>=</span> <span class='boolval'>true</span>; <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)}, <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>l</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>long</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;,--{}=&quot;</span>,<span class='ident'>l</span>)}<span class='kw'>else</span> {<span class='ident'>needs_tab</span> <span class='op'>=</span> <span class='boolval'>true</span>; <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)},
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>v</span>.<span class='ident'>name</span>.<span class='ident'>to_uppercase</span>()), <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>v</span>.<span class='ident'>name</span>),
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>h</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>help</span> {<span class='kw'>if</span> <span class='ident'>needs_tab</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;\t{}&quot;</span>, <span class='op'>*</span><span class='ident'>h</span>)} <span class='kw'>else</span> { <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='op'>*</span><span class='ident'>h</span>) } } <span class='kw'>else</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)} ); <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>h</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>help</span> {<span class='kw'>if</span> <span class='ident'>needs_tab</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;\t{}&quot;</span>, <span class='op'>*</span><span class='ident'>h</span>)} <span class='kw'>else</span> { <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='op'>*</span><span class='ident'>h</span>) } } <span class='kw'>else</span> {<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; &quot;</span>)} );
} }
} }
@ -1357,7 +1359,7 @@
} }
<span class='kw'>fn</span> <span class='ident'>parse_long_arg</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>matches</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>ArgMatches</span> ,<span class='ident'>full_arg</span>: <span class='kw-2'>&amp;</span><span class='ident'>String</span>) <span class='op'>-&gt;</span> <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> { <span class='kw'>fn</span> <span class='ident'>parse_long_arg</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>matches</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>ArgMatches</span> ,<span class='ident'>full_arg</span>: <span class='kw-2'>&amp;</span><span class='ident'>String</span>) <span class='op'>-&gt;</span> <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> {
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>arg</span> <span class='op'>=</span> <span class='ident'>full_arg</span>.<span class='ident'>as_slice</span>().<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>); <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>arg</span> <span class='op'>=</span> <span class='ident'>full_arg</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>);
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>found</span> <span class='op'>=</span> <span class='boolval'>false</span>; <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>found</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>if</span> <span class='ident'>arg</span> <span class='op'>==</span> <span class='string'>&quot;help&quot;</span> <span class='op'>&amp;&amp;</span> <span class='self'>self</span>.<span class='ident'>needs_long_help</span> { <span class='kw'>if</span> <span class='ident'>arg</span> <span class='op'>==</span> <span class='string'>&quot;help&quot;</span> <span class='op'>&amp;&amp;</span> <span class='self'>self</span>.<span class='ident'>needs_long_help</span> {
@ -1436,12 +1438,15 @@
} }
<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'>reqs</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>requires</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'>reqs</span>) <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>requires</span> {
<span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>reqs</span>.<span class='ident'>is_empty</span>() { <span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>reqs</span>.<span class='ident'>is_empty</span>() {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>reqs</span>.<span class='ident'>iter</span>() { <span class='comment'>// Add all required args which aren&#39;t already found in matches to the</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; } <span class='comment'>// final required list</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; } <span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>reqs</span>.<span class='ident'>iter</span>().<span class='ident'>filter</span>(<span class='op'>|</span><span class='kw-2'>&amp;</span><span class='ident'>a</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>positionals</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; } <span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) <span class='op'>||</span>
<span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>insert</span>(<span class='ident'>n</span>); <span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) <span class='op'>||</span>
} <span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>positionals</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) ) {
<span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>insert</span>(<span class='ident'>n</span>);
}
} }
} }
<span class='kw'>break</span>; <span class='kw'>break</span>;
@ -1457,7 +1462,7 @@
} }
<span class='kw'>fn</span> <span class='ident'>parse_short_arg</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>matches</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>ArgMatches</span> ,<span class='ident'>full_arg</span>: <span class='kw-2'>&amp;</span><span class='ident'>String</span>) <span class='op'>-&gt;</span> <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> { <span class='kw'>fn</span> <span class='ident'>parse_short_arg</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>matches</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>ArgMatches</span> ,<span class='ident'>full_arg</span>: <span class='kw-2'>&amp;</span><span class='ident'>String</span>) <span class='op'>-&gt;</span> <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> {
<span class='kw'>let</span> <span class='ident'>arg</span> <span class='op'>=</span> <span class='ident'>full_arg</span>.<span class='ident'>as_slice</span>().<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>); <span class='kw'>let</span> <span class='ident'>arg</span> <span class='op'>=</span> <span class='kw-2'>&amp;</span><span class='ident'>full_arg</span>[..].<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>);
<span class='kw'>if</span> <span class='ident'>arg</span>.<span class='ident'>len</span>() <span class='op'>&gt;</span> <span class='number'>1</span> { <span class='kw'>if</span> <span class='ident'>arg</span>.<span class='ident'>len</span>() <span class='op'>&gt;</span> <span class='number'>1</span> {
<span class='comment'>// Multiple flags using short i.e. -bgHlS</span> <span class='comment'>// Multiple flags using short i.e. -bgHlS</span>
<span class='kw'>for</span> <span class='ident'>c</span> <span class='kw'>in</span> <span class='ident'>arg</span>.<span class='ident'>chars</span>() { <span class='kw'>for</span> <span class='ident'>c</span> <span class='kw'>in</span> <span class='ident'>arg</span>.<span class='ident'>chars</span>() {
@ -1470,7 +1475,7 @@
} }
} <span class='kw'>else</span> { } <span class='kw'>else</span> {
<span class='comment'>// Short flag or opt</span> <span class='comment'>// Short flag or opt</span>
<span class='kw'>let</span> <span class='ident'>arg_c</span> <span class='op'>=</span> <span class='ident'>arg</span>.<span class='ident'>char_at</span>(<span class='number'>0</span>); <span class='kw'>let</span> <span class='ident'>arg_c</span> <span class='op'>=</span> <span class='ident'>arg</span>.<span class='ident'>chars</span>().<span class='ident'>nth</span>(<span class='number'>0</span>).<span class='ident'>unwrap</span>();
<span class='self'>self</span>.<span class='ident'>check_for_help_and_version</span>(<span class='ident'>arg_c</span>); <span class='self'>self</span>.<span class='ident'>check_for_help_and_version</span>(<span class='ident'>arg_c</span>);
<span class='kw'>if</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>parse_single_short_flag</span>(<span class='ident'>matches</span>, <span class='ident'>arg_c</span>) { <span class='kw'>if</span> <span class='op'>!</span> <span class='self'>self</span>.<span class='ident'>parse_single_short_flag</span>(<span class='ident'>matches</span>, <span class='ident'>arg_c</span>) {
@ -1613,66 +1618,74 @@
<span class='kw'>fn</span> <span class='ident'>get_matches_from</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>matches</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>ArgMatches</span>, <span class='ident'>it</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>IntoIter</span><span class='op'>&lt;</span><span class='ident'>String</span><span class='op'>&gt;</span>) { <span class='kw'>fn</span> <span class='ident'>get_matches_from</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>matches</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>ArgMatches</span>, <span class='ident'>it</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>IntoIter</span><span class='op'>&lt;</span><span class='ident'>String</span><span class='op'>&gt;</span>) {
<span class='self'>self</span>.<span class='ident'>create_help_and_version</span>(); <span class='self'>self</span>.<span class='ident'>create_help_and_version</span>();
<span class='comment'>// let mut needs_val = false;</span> <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>pos_only</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>subcmd_name</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>subcmd_name</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='prelude-val'>None</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>needs_val_of</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>needs_val_of</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='prelude-val'>None</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>pos_counter</span> <span class='op'>=</span> <span class='number'>1</span>; <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>pos_counter</span> <span class='op'>=</span> <span class='number'>1</span>;
<span class='kw'>while</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>arg</span>) <span class='op'>=</span> <span class='ident'>it</span>.<span class='ident'>next</span>() { <span class='kw'>while</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>arg</span>) <span class='op'>=</span> <span class='ident'>it</span>.<span class='ident'>next</span>() {
<span class='kw'>let</span> <span class='ident'>arg_slice</span> <span class='op'>=</span> <span class='ident'>arg</span>.<span class='ident'>as_slice</span>(); <span class='kw'>let</span> <span class='ident'>arg_slice</span> <span class='op'>=</span> <span class='kw-2'>&amp;</span><span class='ident'>arg</span>[..];
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>skip</span> <span class='op'>=</span> <span class='boolval'>false</span>; <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>skip</span> <span class='op'>=</span> <span class='boolval'>false</span>;
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>nvo</span>) <span class='op'>=</span> <span class='ident'>needs_val_of</span> { <span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>pos_only</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>opt</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>get</span>(<span class='ident'>nvo</span>) { <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>nvo</span>) <span class='op'>=</span> <span class='ident'>needs_val_of</span> {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>contains</span>(<span class='ident'>opt</span>.<span class='ident'>name</span>) { <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>opt</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>get</span>(<span class='ident'>nvo</span>) {
<span class='self'>self</span>.<span class='ident'>report_error</span>( <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>contains</span>(<span class='ident'>opt</span>.<span class='ident'>name</span>) {
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument {} is mutually exclusive with one or more other arguments&quot;</span>, <span class='self'>self</span>.<span class='ident'>report_error</span>(
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>long</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>long</span> { <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;The argument {} is mutually exclusive with one or more other arguments&quot;</span>,
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;--{}&quot;</span>,<span class='ident'>long</span>) <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>long</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>long</span> {
}<span class='kw'>else</span>{ <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;--{}&quot;</span>,<span class='ident'>long</span>)
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{}&quot;</span>,<span class='ident'>opt</span>.<span class='ident'>short</span>.<span class='ident'>unwrap</span>()) }<span class='kw'>else</span>{
}),<span class='boolval'>true</span>, <span class='boolval'>true</span>); <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;-{}&quot;</span>,<span class='ident'>opt</span>.<span class='ident'>short</span>.<span class='ident'>unwrap</span>())
} }),<span class='boolval'>true</span>, <span class='boolval'>true</span>);
<span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>insert</span>(<span class='ident'>nvo</span>, <span class='ident'>OptArg</span>{ }
<span class='ident'>name</span>: <span class='ident'>opt</span>.<span class='ident'>name</span>, <span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>insert</span>(<span class='ident'>nvo</span>, <span class='ident'>OptArg</span>{
<span class='ident'>short</span>: <span class='ident'>opt</span>.<span class='ident'>short</span>, <span class='ident'>name</span>: <span class='ident'>opt</span>.<span class='ident'>name</span>,
<span class='ident'>long</span>: <span class='ident'>opt</span>.<span class='ident'>long</span>, <span class='ident'>short</span>: <span class='ident'>opt</span>.<span class='ident'>short</span>,
<span class='ident'>help</span>: <span class='ident'>opt</span>.<span class='ident'>help</span>, <span class='ident'>long</span>: <span class='ident'>opt</span>.<span class='ident'>long</span>,
<span class='ident'>requires</span>: <span class='prelude-val'>None</span>, <span class='ident'>help</span>: <span class='ident'>opt</span>.<span class='ident'>help</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='ident'>required</span>: <span class='ident'>opt</span>.<span class='ident'>required</span>, <span class='ident'>blacklist</span>: <span class='prelude-val'>None</span>,
<span class='ident'>value</span>: <span class='prelude-val'>Some</span>(<span class='ident'>arg</span>.<span class='ident'>clone</span>()) <span class='ident'>required</span>: <span class='ident'>opt</span>.<span class='ident'>required</span>,
}); <span class='ident'>value</span>: <span class='prelude-val'>Some</span>(<span class='ident'>arg</span>.<span class='ident'>clone</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'>bl</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>blacklist</span> { });
<span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>bl</span>.<span class='ident'>is_empty</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'>bl</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>blacklist</span> {
<span class='kw'>for</span> <span class='ident'>name</span> <span class='kw'>in</span> <span class='ident'>bl</span>.<span class='ident'>iter</span>() { <span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>bl</span>.<span class='ident'>is_empty</span>() {
<span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>insert</span>(<span class='ident'>name</span>); <span class='kw'>for</span> <span class='ident'>name</span> <span class='kw'>in</span> <span class='ident'>bl</span>.<span class='ident'>iter</span>() {
<span class='self'>self</span>.<span class='ident'>blacklist</span>.<span class='ident'>insert</span>(<span class='ident'>name</span>);
}
} }
} }
} <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>contains</span>(<span class='ident'>opt</span>.<span class='ident'>name</span>) {
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>contains</span>(<span class='ident'>opt</span>.<span class='ident'>name</span>) { <span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>remove</span>(<span class='ident'>opt</span>.<span class='ident'>name</span>);
<span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>remove</span>(<span class='ident'>opt</span>.<span class='ident'>name</span>);
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>reqs</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>requires</span> {
<span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>reqs</span>.<span class='ident'>is_empty</span>() {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>reqs</span>.<span class='ident'>iter</span>() {
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; }
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; }
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>positionals</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; }
<span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>insert</span>(<span class='ident'>n</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'>reqs</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>requires</span> {
<span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>reqs</span>.<span class='ident'>is_empty</span>() {
<span class='comment'>// Add all required args which aren&#39;t already found in matches to the</span>
<span class='comment'>// final required list</span>
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>reqs</span>.<span class='ident'>iter</span>().<span class='ident'>filter</span>(<span class='op'>|</span><span class='kw-2'>&amp;</span><span class='ident'>a</span><span class='op'>|</span>
<span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) <span class='op'>||</span>
<span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) <span class='op'>||</span>
<span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>positionals</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) ) {
<span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>insert</span>(<span class='ident'>n</span>);
}
}
}
<span class='ident'>skip</span> <span class='op'>=</span> <span class='boolval'>true</span>;
} }
<span class='ident'>skip</span> <span class='op'>=</span> <span class='boolval'>true</span>;
} }
} }
<span class='kw'>if</span> <span class='ident'>skip</span> { <span class='kw'>if</span> <span class='ident'>skip</span> {
<span class='ident'>needs_val_of</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; <span class='ident'>needs_val_of</span> <span class='op'>=</span> <span class='prelude-val'>None</span>;
<span class='kw'>continue</span>; <span class='kw'>continue</span>;
} }
<span class='kw'>if</span> <span class='ident'>arg_slice</span>.<span class='ident'>starts_with</span>(<span class='string'>&quot;--&quot;</span>) { <span class='kw'>if</span> <span class='ident'>arg_slice</span>.<span class='ident'>starts_with</span>(<span class='string'>&quot;--&quot;</span>) <span class='op'>&amp;&amp;</span> <span class='op'>!</span> <span class='ident'>pos_only</span> {
<span class='kw'>if</span> <span class='ident'>arg_slice</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>2</span> {
<span class='ident'>pos_only</span> <span class='op'>=</span> <span class='boolval'>true</span>;
<span class='kw'>continue</span>;
}
<span class='comment'>// Single flag, or option long version</span> <span class='comment'>// Single flag, or option long version</span>
<span class='ident'>needs_val_of</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>parse_long_arg</span>(<span class='ident'>matches</span>, <span class='kw-2'>&amp;</span><span class='ident'>arg</span>); <span class='ident'>needs_val_of</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>parse_long_arg</span>(<span class='ident'>matches</span>, <span class='kw-2'>&amp;</span><span class='ident'>arg</span>);
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>arg_slice</span>.<span class='ident'>starts_with</span>(<span class='string'>&quot;-&quot;</span>) <span class='op'>&amp;&amp;</span> <span class='ident'>arg_slice</span>.<span class='ident'>len</span>() <span class='op'>!=</span> <span class='number'>1</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span> <span class='ident'>pos_only</span> {
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>arg_slice</span>.<span class='ident'>starts_with</span>(<span class='string'>&quot;-&quot;</span>) {
<span class='ident'>needs_val_of</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>parse_short_arg</span>(<span class='ident'>matches</span>, <span class='kw-2'>&amp;</span><span class='ident'>arg</span>); <span class='ident'>needs_val_of</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>parse_short_arg</span>(<span class='ident'>matches</span>, <span class='kw-2'>&amp;</span><span class='ident'>arg</span>);
} <span class='kw'>else</span> { } <span class='kw'>else</span> {
<span class='comment'>// Positional or Subcommand</span> <span class='comment'>// Positional or Subcommand</span>
@ -1684,7 +1697,7 @@
<span class='kw'>break</span>; <span class='kw'>break</span>;
} }
<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>is_empty</span>() { <span class='comment'>// || self.positionals_name.is_empty() {</span> <span class='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'>&quot;Found positional argument {}, but {} doesn&#39;t accept any&quot;</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>name</span>), <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;Found positional argument {}, but {} doesn&#39;t accept any&quot;</span>, <span class='ident'>arg</span>, <span class='self'>self</span>.<span class='ident'>name</span>),
<span class='boolval'>true</span>, <span class='boolval'>true</span>); <span class='boolval'>true</span>, <span class='boolval'>true</span>);
@ -1715,11 +1728,14 @@
} }
<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'>reqs</span>) <span class='op'>=</span> <span class='ident'>p</span>.<span class='ident'>requires</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'>reqs</span>) <span class='op'>=</span> <span class='ident'>p</span>.<span class='ident'>requires</span> {
<span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>reqs</span>.<span class='ident'>is_empty</span>() { <span class='kw'>if</span> <span class='op'>!</span> <span class='ident'>reqs</span>.<span class='ident'>is_empty</span>() {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>reqs</span>.<span class='ident'>iter</span>() { <span class='comment'>// Add all required args which aren&#39;t already found in matches to the</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; } <span class='comment'>// final required list</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; } <span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>reqs</span>.<span class='ident'>iter</span>().<span class='ident'>filter</span>(<span class='op'>|</span><span class='kw-2'>&amp;</span><span class='ident'>a</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>positionals</span>.<span class='ident'>contains_key</span>(<span class='ident'>n</span>) { <span class='kw'>continue</span>; } <span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>opts</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) <span class='op'>||</span>
<span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>insert</span>(<span class='ident'>n</span>); <span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>flags</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) <span class='op'>||</span>
<span class='op'>!</span> <span class='ident'>matches</span>.<span class='ident'>positionals</span>.<span class='ident'>contains_key</span>(<span class='ident'>a</span>) ) {
<span class='self'>self</span>.<span class='ident'>required</span>.<span class='ident'>insert</span>(<span class='ident'>n</span>);
} }
} }
} }

View file

@ -4,12 +4,12 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc"> <meta name="generator" content="rustdoc">
<meta name="description" content="Source to the Rust file `src/arg.rs`."> <meta name="description" content="Source to the Rust file `src/args/arg.rs`.">
<meta name="keywords" content="rust, rustlang, rust-lang"> <meta name="keywords" content="rust, rustlang, rust-lang">
<title>arg.rs.html -- source</title> <title>arg.rs.html -- source</title>
<link rel="stylesheet" type="text/css" href="../../../main.css"> <link rel="stylesheet" type="text/css" href="../../../../main.css">
@ -377,7 +377,6 @@
<span id="335">335</span> <span id="335">335</span>
<span id="336">336</span> <span id="336">336</span>
<span id="337">337</span> <span id="337">337</span>
<span id="338">338</span>
</pre><pre class='rust '> </pre><pre class='rust '>
<span class='doccomment'>/// The abstract representation of a command line argument used by the consumer of the library.</span> <span class='doccomment'>/// The abstract representation of a command line argument used by the consumer of the library.</span>
<span class='doccomment'>/// </span> <span class='doccomment'>/// </span>
@ -486,8 +485,7 @@
<span class='doccomment'>/// .short(&quot;c&quot;)</span> <span class='doccomment'>/// .short(&quot;c&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span> <span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>short</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> { <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>short</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>short</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>) <span class='self'>self</span>.<span class='ident'>short</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>).<span class='ident'>chars</span>().<span class='ident'>nth</span>(<span class='number'>0</span>);
.<span class='ident'>char_at</span>(<span class='number'>0</span>));
<span class='self'>self</span> <span class='self'>self</span>
} }
@ -757,13 +755,13 @@
<script> <script>
window.rootPath = "../../../"; window.rootPath = "../../../../";
window.currentCrate = "clap"; window.currentCrate = "clap";
window.playgroundUrl = ""; window.playgroundUrl = "";
</script> </script>
<script src="../../../jquery.js"></script> <script src="../../../../jquery.js"></script>
<script src="../../../main.js"></script> <script src="../../../../main.js"></script>
<script async src="../../../search-index.js"></script> <script async src="../../../../search-index.js"></script>
</body> </body>
</html> </html>

View file

@ -4,12 +4,12 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc"> <meta name="generator" content="rustdoc">
<meta name="description" content="Source to the Rust file `src/argmatches.rs`."> <meta name="description" content="Source to the Rust file `src/args/argmatches.rs`.">
<meta name="keywords" content="rust, rustlang, rust-lang"> <meta name="keywords" content="rust, rustlang, rust-lang">
<title>argmatches.rs.html -- source</title> <title>argmatches.rs.html -- source</title>
<link rel="stylesheet" type="text/css" href="../../../main.css"> <link rel="stylesheet" type="text/css" href="../../../../main.css">
@ -246,12 +246,10 @@
<span id="204">204</span> <span id="204">204</span>
<span id="205">205</span> <span id="205">205</span>
<span id="206">206</span> <span id="206">206</span>
<span id="207">207</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>;
<span class='kw'>use</span> <span class='ident'>args</span>::{ <span class='ident'>FlagArg</span>, <span class='ident'>OptArg</span>, <span class='ident'>PosArg</span> }; <span class='kw'>use</span> <span class='ident'>args</span>::{ <span class='ident'>FlagArg</span>, <span class='ident'>OptArg</span>, <span class='ident'>PosArg</span>, <span class='ident'>SubCommand</span> };
<span class='kw'>use</span> <span class='ident'>subcommand</span>::<span class='ident'>SubCommand</span>;
<span class='doccomment'>/// Used to get information about the arguments that</span> <span class='doccomment'>/// Used to get information about the arguments that</span>
<span class='doccomment'>/// where supplied to the program at runtime.</span> <span class='doccomment'>/// where supplied to the program at runtime.</span>
@ -495,13 +493,13 @@
<script> <script>
window.rootPath = "../../../"; window.rootPath = "../../../../";
window.currentCrate = "clap"; window.currentCrate = "clap";
window.playgroundUrl = ""; window.playgroundUrl = "";
</script> </script>
<script src="../../../jquery.js"></script> <script src="../../../../jquery.js"></script>
<script src="../../../main.js"></script> <script src="../../../../main.js"></script>
<script async src="../../../search-index.js"></script> <script async src="../../../../search-index.js"></script>
</body> </body>
</html> </html>

View file

@ -0,0 +1,119 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="Source to the Rust file `src/args/mod.rs`.">
<meta name="keywords" content="rust, rustlang, rust-lang">
<title>mod.rs.html -- source</title>
<link rel="stylesheet" type="text/css" href="../../../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<section class="sidebar">
</section>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press 'S' to search, '?' for more options..."
type="search">
</div>
</form>
</nav>
<section id='main' class="content source"><pre class="line-numbers"><span id="1"> 1</span>
<span id="2"> 2</span>
<span id="3"> 3</span>
<span id="4"> 4</span>
<span id="5"> 5</span>
<span id="6"> 6</span>
<span id="7"> 7</span>
<span id="8"> 8</span>
<span id="9"> 9</span>
<span id="10">10</span>
<span id="11">11</span>
<span id="12">12</span>
<span id="13">13</span>
</pre><pre class='rust '>
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>arg</span>::<span class='ident'>Arg</span>;
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>argmatches</span>::<span class='ident'>ArgMatches</span>;
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>flagarg</span>::<span class='ident'>FlagArg</span>;
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>optarg</span>::<span class='ident'>OptArg</span>;
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>posarg</span>::<span class='ident'>PosArg</span>;
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>subcommand</span>::<span class='ident'>SubCommand</span>;
<span class='kw'>mod</span> <span class='ident'>arg</span>;
<span class='kw'>mod</span> <span class='ident'>argmatches</span>;
<span class='kw'>mod</span> <span class='ident'>flagarg</span>;
<span class='kw'>mod</span> <span class='ident'>optarg</span>;
<span class='kw'>mod</span> <span class='ident'>posarg</span>;
<span class='kw'>mod</span> <span class='ident'>subcommand</span>;
</pre>
</section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<div id="help" class="hidden">
<div class="shortcuts">
<h1>Keyboard shortcuts</h1>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
</dl>
</div>
<div class="infos">
<h1>Search tricks</h1>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>typedef</code> (or
<code>tdef</code>).
</p>
</div>
</div>
<script>
window.rootPath = "../../../../";
window.currentCrate = "clap";
window.playgroundUrl = "";
</script>
<script src="../../../../jquery.js"></script>
<script src="../../../../main.js"></script>
<script async src="../../../../search-index.js"></script>
</body>
</html>

View file

@ -4,12 +4,12 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc"> <meta name="generator" content="rustdoc">
<meta name="description" content="Source to the Rust file `src/subcommand.rs`."> <meta name="description" content="Source to the Rust file `src/args/subcommand.rs`.">
<meta name="keywords" content="rust, rustlang, rust-lang"> <meta name="keywords" content="rust, rustlang, rust-lang">
<title>subcommand.rs.html -- source</title> <title>subcommand.rs.html -- source</title>
<link rel="stylesheet" type="text/css" href="../../../main.css"> <link rel="stylesheet" type="text/css" href="../../../../main.css">
@ -84,8 +84,8 @@
<span id="42">42</span> <span id="42">42</span>
<span id="43">43</span> <span id="43">43</span>
</pre><pre class='rust '> </pre><pre class='rust '>
<span class='kw'>use</span> <span class='ident'>app</span>::<span class='ident'>App</span>; <span class='kw'>use</span> <span class='ident'>App</span>;
<span class='kw'>use</span> <span class='ident'>argmatches</span>::<span class='ident'>ArgMatches</span>; <span class='kw'>use</span> <span class='ident'>ArgMatches</span>;
<span class='doccomment'>/// The abstract representation of a command line subcommand used by the consumer of the library.</span> <span class='doccomment'>/// The abstract representation of a command line subcommand used by the consumer of the library.</span>
<span class='doccomment'>/// </span> <span class='doccomment'>/// </span>
@ -167,13 +167,13 @@
<script> <script>
window.rootPath = "../../../"; window.rootPath = "../../../../";
window.currentCrate = "clap"; window.currentCrate = "clap";
window.playgroundUrl = ""; window.playgroundUrl = "";
</script> </script>
<script src="../../../jquery.js"></script> <script src="../../../../jquery.js"></script>
<script src="../../../main.js"></script> <script src="../../../../main.js"></script>
<script async src="../../../search-index.js"></script> <script async src="../../../../search-index.js"></script>
</body> </body>
</html> </html>

View file

@ -190,15 +190,10 @@
<span id="148">148</span> <span id="148">148</span>
<span id="149">149</span> <span id="149">149</span>
<span id="150">150</span> <span id="150">150</span>
<span id="151">151</span>
<span id="152">152</span>
<span id="153">153</span>
<span id="154">154</span>
<span id="155">155</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'>&quot;lib&quot;</span>]</span> <span class='attribute'>#<span class='op'>!</span>[<span class='ident'>crate_type</span><span class='op'>=</span> <span class='string'>&quot;lib&quot;</span>]</span>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>collections</span>, <span class='ident'>core</span>, <span class='ident'>libc</span>, <span class='ident'>exit_status</span>)]</span> <span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>libc</span>, <span class='ident'>exit_status</span>)]</span>
<span class='doccomment'>//! A simply library for parsing command line arguments when writing </span> <span class='doccomment'>//! A simply library for parsing command line arguments when writing </span>
<span class='doccomment'>//! command line and console applications.</span> <span class='doccomment'>//! command line and console applications.</span>
@ -224,22 +219,22 @@
<span class='doccomment'>//! .author(&quot;Kevin K. &lt;kbknapp@gmail.com&gt;&quot;)</span> <span class='doccomment'>//! .author(&quot;Kevin K. &lt;kbknapp@gmail.com&gt;&quot;)</span>
<span class='doccomment'>//! .about(&quot;Does awesome things&quot;)</span> <span class='doccomment'>//! .about(&quot;Does awesome things&quot;)</span>
<span class='doccomment'>//! .arg(Arg::new(&quot;config&quot;)</span> <span class='doccomment'>//! .arg(Arg::new(&quot;config&quot;)</span>
<span class='doccomment'>//! .short(&quot;c&quot;)</span> <span class='doccomment'>//! .short(&quot;c&quot;)</span>
<span class='doccomment'>//! .long(&quot;config&quot;)</span> <span class='doccomment'>//! .long(&quot;config&quot;)</span>
<span class='doccomment'>//! .help(&quot;Sets a custom config file&quot;)</span> <span class='doccomment'>//! .help(&quot;Sets a custom config file&quot;)</span>
<span class='doccomment'>//! .takes_value(true))</span> <span class='doccomment'>//! .takes_value(true))</span>
<span class='doccomment'>//! .arg(Arg::new(&quot;output&quot;)</span> <span class='doccomment'>//! .arg(Arg::new(&quot;output&quot;)</span>
<span class='doccomment'>//! .help(&quot;Sets an optional output file&quot;)</span> <span class='doccomment'>//! .help(&quot;Sets an optional output file&quot;)</span>
<span class='doccomment'>//! .index(1))</span> <span class='doccomment'>//! .index(1))</span>
<span class='doccomment'>//! .arg(Arg::new(&quot;debug&quot;)</span> <span class='doccomment'>//! .arg(Arg::new(&quot;debug&quot;)</span>
<span class='doccomment'>//! .short(&quot;d&quot;)</span> <span class='doccomment'>//! .short(&quot;d&quot;)</span>
<span class='doccomment'>//! .multiple(true)</span> <span class='doccomment'>//! .multiple(true)</span>
<span class='doccomment'>//! .help(&quot;Turn debugging information on&quot;))</span> <span class='doccomment'>//! .help(&quot;Turn debugging information on&quot;))</span>
<span class='doccomment'>//! .subcommand(SubCommand::new(&quot;test&quot;)</span> <span class='doccomment'>//! .subcommand(SubCommand::new(&quot;test&quot;)</span>
<span class='doccomment'>//! .about(&quot;Has test sub functionality&quot;)</span> <span class='doccomment'>//! .about(&quot;Has test sub functionality&quot;)</span>
<span class='doccomment'>//! .arg(Arg::new(&quot;verbose&quot;)</span> <span class='doccomment'>//! .arg(Arg::new(&quot;verbose&quot;)</span>
<span class='doccomment'>//! .short(&quot;v&quot;)</span> <span class='doccomment'>//! .short(&quot;v&quot;)</span>
<span class='doccomment'>//! .help(&quot;Display verbose information&quot;)))</span> <span class='doccomment'>//! .help(&quot;Display verbose information&quot;)))</span>
<span class='doccomment'>//! .get_matches();</span> <span class='doccomment'>//! .get_matches();</span>
<span class='doccomment'>//!</span> <span class='doccomment'>//!</span>
<span class='doccomment'>//! if let Some(o) = matches.value_of(&quot;output&quot;) {</span> <span class='doccomment'>//! if let Some(o) = matches.value_of(&quot;output&quot;) {</span>
@ -256,7 +251,7 @@
<span class='doccomment'>//! 2 =&gt; println!(&quot;Debug mode is on&quot;),</span> <span class='doccomment'>//! 2 =&gt; println!(&quot;Debug mode is on&quot;),</span>
<span class='doccomment'>//! 3 | _ =&gt; println!(&quot;Don&#39;t be crazy&quot;),</span> <span class='doccomment'>//! 3 | _ =&gt; println!(&quot;Don&#39;t be crazy&quot;),</span>
<span class='doccomment'>//! }</span> <span class='doccomment'>//! }</span>
<span class='doccomment'>//! </span> <span class='doccomment'>//!</span>
<span class='doccomment'>//! if let Some(ref matches) = matches.subcommand_matches(&quot;test&quot;) {</span> <span class='doccomment'>//! if let Some(ref matches) = matches.subcommand_matches(&quot;test&quot;) {</span>
<span class='doccomment'>//! if matches.is_present(&quot;verbose&quot;) {</span> <span class='doccomment'>//! if matches.is_present(&quot;verbose&quot;) {</span>
<span class='doccomment'>//! println!(&quot;Printing verbose test info...&quot;);</span> <span class='doccomment'>//! println!(&quot;Printing verbose test info...&quot;);</span>
@ -295,16 +290,11 @@
<span class='doccomment'>//! test Has test sub-functionality</span> <span class='doccomment'>//! test Has test sub-functionality</span>
<span class='doccomment'>//! ```</span> <span class='doccomment'>//! ```</span>
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>argmatches</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'>arg</span>::<span class='ident'>Arg</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='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>subcommand</span>::<span class='ident'>SubCommand</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'>argmatches</span>;
<span class='kw'>mod</span> <span class='ident'>arg</span>;
<span class='kw'>mod</span> <span class='ident'>args</span>; <span class='kw'>mod</span> <span class='ident'>args</span>;
<span class='kw'>mod</span> <span class='ident'>subcommand</span>;
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span>
<span class='kw'>mod</span> <span class='ident'>tests</span> { <span class='kw'>mod</span> <span class='ident'>tests</span> {