docs(clap): clean up docs and add better explainations

This commit is contained in:
Kevin K 2015-04-10 19:21:34 -04:00
parent 2e3dc49a9a
commit 3d960e8be0
15 changed files with 229 additions and 182 deletions

View file

@ -1 +1 @@
initSidebarItems({"struct":[["Arg","The abstract representation of a command line argument used by the consumer of the library."]]});
initSidebarItems({"struct":[["Arg","The abstract representation of a command line argument used by the consumer of the library. Used to set all the options and relationships that define a valid argument for the program."]]});

View file

@ -1 +1 @@
initSidebarItems({"struct":[["ArgMatches","Used to get information about the arguments that where supplied to the program at runtime."]]});
initSidebarItems({"struct":[["ArgMatches","Used to get information about the arguments that where supplied to the program at runtime by the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct."]]});

View file

@ -315,15 +315,16 @@ for parsing at runtime.</p>
<tr>
<td><a class='stability Unmarked' title='No stability level'></a><a class='struct' href='struct.Arg.html'
title='clap::Arg'>Arg</a></td>
<td class='docblock short'><p>The abstract representation of a command line argument used by the consumer of the library.</p>
<td class='docblock short'><p>The abstract representation of a command line argument used by the consumer of the library.
Used to set all the options and relationships that define a valid argument for the program.</p>
</td>
</tr>
<tr>
<td><a class='stability Unmarked' title='No stability level'></a><a class='struct' href='struct.ArgMatches.html'
title='clap::ArgMatches'>ArgMatches</a></td>
<td class='docblock short'><p>Used to get information about the arguments that
where supplied to the program at runtime.</p>
<td class='docblock short'><p>Used to get information about the arguments that where supplied to the program at runtime by
the user. To get a new instance of this struct you use <code>.get_matches()</code> of the <code>App</code> struct.</p>
</td>
</tr>

View file

@ -1 +1 @@
initSidebarItems({"struct":[["App","Used to create a representation of the program and all possible command line arguments for parsing at runtime."],["Arg","The abstract representation of a command line argument used by the consumer of the library."],["ArgMatches","Used to get information about the arguments that where supplied to the program at runtime."],["SubCommand","The abstract representation of a command line subcommand used by the consumer of the library."]]});
initSidebarItems({"struct":[["App","Used to create a representation of the program and all possible command line arguments for parsing at runtime."],["Arg","The abstract representation of a command line argument used by the consumer of the library. Used to set all the options and relationships that define a valid argument for the program."],["ArgMatches","Used to get information about the arguments that where supplied to the program at runtime by the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct."],["SubCommand","The abstract representation of a command line subcommand used by the consumer of the library."]]});

View file

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

View file

@ -75,34 +75,38 @@ to the user when they print version or help and usage information.</p>
<span class='kw'>let</span> <span class='ident'>prog</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;myprog&quot;</span>)
</pre>
</div><h4 id='method.author' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.author' class='fnname'>author</a>(self, a: &amp;'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&lt;'a, 'v, 'ab, 'u, 'ar&gt;</code></h4>
<div class='docblock'><p>Sets a string of author(s)</p>
<div class='docblock'><p>Sets a string of author(s) and will be showed to the user when displaying help inofrmation</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<span class='ident'>author</span>(<span class='string'>&quot;Kevin &lt;kbknapp@gmail.com&gt;&quot;</span>)
</pre>
</div><h4 id='method.about' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.about' class='fnname'>about</a>(self, a: &amp;'ab <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&lt;'a, 'v, 'ab, 'u, 'ar&gt;</code></h4>
<div class='docblock'><p>Sets a string briefly describing what the program does</p>
<div class='docblock'><p>Sets a string briefly describing what the program does and will be displayed when
displaying help information.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<span class='ident'>about</span>(<span class='string'>&quot;Does really amazing things to great people&quot;</span>)
</pre>
</div><h4 id='method.version' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.version' class='fnname'>version</a>(self, v: &amp;'v <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&lt;'a, 'v, 'ab, 'u, 'ar&gt;</code></h4>
<div class='docblock'><p>Sets a string of the version number</p>
<div class='docblock'><p>Sets a string of the version number to be displayed when displaying version or help
information.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<span class='ident'>version</span>(<span class='string'>&quot;v0.1.24&quot;</span>)
</pre>
</div><h4 id='method.usage' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.usage' class='fnname'>usage</a>(self, u: &amp;'u <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&lt;'a, 'v, 'ab, 'u, 'ar&gt;</code></h4>
<div class='docblock'><p>Sets a custom usage string to over-ride the one auto-generated by <code>clap</code></p>
<div class='docblock'><p>Sets a custom usage string to over-ride the one auto-generated by <code>clap</code>. Will be
displayed to the user when errors are found in argument parsing, or when you call
<code>.usage()</code> of <code>ArgMatches</code></p>
<p><em>NOTE:</em> You do not need to specify the &quot;USAGE: &quot; portion, as that will
<p><em>NOTE:</em> You do not need to specify the &quot;USAGE: \n\t&quot; portion, as that will
still be applied by <code>clap</code>, you only need to specify the portion starting
with the binary name. </p>
<p><em>NOTE:</em> This will not replace the entire help message, only the portion
<p><em>NOTE:</em> This will not replace the entire help message, <em>only</em> the portion
showing the usage.</p>
<h1 id="example" class='section-header'><a
@ -128,10 +132,10 @@ showing the usage.</p>
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;debug&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;d&quot;</span>)])
</pre>
</div><h4 id='method.subcommand' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.subcommand' class='fnname'>subcommand</a>(self, subcmd: <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&lt;'a, 'v, 'ab, 'u, 'ar&gt;) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&lt;'a, 'v, 'ab, 'u, 'ar&gt;</code></h4>
<div class='docblock'><p>Adds a subcommand to the list of valid possibilties. Subcommands
are effectively sub apps, because they can contain their own arguments
and subcommands. They also function just like apps, in that they get their
own auto generated help and version switches.</p>
<div class='docblock'><p>Adds a subcommand to the list of valid possibilties. Subcommands are effectively sub apps,
because they can contain their own arguments, subcommands, version, usage, etc. They also
function just like apps, in that they get their own auto generated help and version
switches.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>

View file

@ -43,25 +43,15 @@
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>Arg</a><wbr></span><span class='out-of-band'><span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-8370' 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-66'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Arg&lt;'n, 'l, 'h, 'b, 'p, 'r&gt; {
pub name: &amp;'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>&lt;<a href='http://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>&gt;,
pub long: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;'l <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;,
pub help: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;'h <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;,
pub required: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>,
pub takes_value: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>,
pub index: <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.u8.html'>u8</a>&gt;,
pub multiple: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>,
pub blacklist: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'b <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;&gt;,
pub possible_vals: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'p <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;&gt;,
pub requires: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'r <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;&gt;,
}</pre><div class='docblock'><p>The abstract representation of a command line argument used by the consumer of the library.</p>
// some fields omitted
}</pre><div class='docblock'><p>The abstract representation of a command line argument used by the consumer of the library.
Used to set all the options and relationships that define a valid argument for the program.</p>
<p>This struct is used by the library consumer and describes the command line arguments for
their program.
and then evaluates the settings the consumer provided and determines the concret
argument struct to use when parsing.</p>
their program. Then evaluates the settings the consumer provided and determines the concret
argument type to use when parsing.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
@ -71,30 +61,7 @@ argument struct to use when parsing.</p>
.<span class='ident'>takes_value</span>(<span class='boolval'>true</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Provides a config file to myprog&quot;</span>)
</pre>
</div><h2 class='fields'>Fields</h2>
<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 unique name of the argument, required</p>
</div></td></tr><tr><td id='structfield.short'><a class='stability Unmarked' title='No stability level'></a><code>short</code></td><td><div class='docblock'><p>The short version (i.e. single character) of the argument, no preceding <code>-</code>
<strong>NOTE:</strong> <code>short</code> is mutually exclusive with <code>index</code></p>
</div></td></tr><tr><td id='structfield.long'><a class='stability Unmarked' title='No stability level'></a><code>long</code></td><td><div class='docblock'><p>The long version of the flag (i.e. word) without the preceding <code>--</code>
<strong>NOTE:</strong> <code>long</code> is mutually exclusive with <code>index</code></p>
</div></td></tr><tr><td id='structfield.help'><a class='stability Unmarked' title='No stability level'></a><code>help</code></td><td><div class='docblock'><p>The string of text that will displayed to the user when the application&#39;s
<code>help</code> text is displayed</p>
</div></td></tr><tr><td id='structfield.required'><a class='stability Unmarked' title='No stability level'></a><code>required</code></td><td><div class='docblock'><p>If this is a required by default when using the command line program
i.e. a configuration file that&#39;s required for the program to function
<strong>NOTE:</strong> required by default means, it is required <em>until</em> mutually
exclusive arguments are evaluated.</p>
</div></td></tr><tr><td id='structfield.takes_value'><a class='stability Unmarked' title='No stability level'></a><code>takes_value</code></td><td><div class='docblock'><p>Determines if this argument is an option, vice a flag or positional and
is mutually exclusive with <code>index</code> and <code>multiple</code></p>
</div></td></tr><tr><td id='structfield.index'><a class='stability Unmarked' title='No stability level'></a><code>index</code></td><td><div class='docblock'><p>The index of the argument. <code>index</code> is mutually exclusive with <code>takes_value</code>
and <code>multiple</code></p>
</div></td></tr><tr><td id='structfield.multiple'><a class='stability Unmarked' title='No stability level'></a><code>multiple</code></td><td><div class='docblock'><p>Determines if multiple instances of the same flag are allowed. <code>multiple</code>
is mutually exclusive with <code>index</code> and <code>takes_value</code>.
I.e. <code>-v -v -v</code> or <code>-vvv</code></p>
</div></td></tr><tr><td id='structfield.blacklist'><a class='stability Unmarked' title='No stability level'></a><code>blacklist</code></td><td><div class='docblock'><p>A list of names for other arguments that <em>may not</em> be used with this flag</p>
</div></td></tr><tr><td id='structfield.possible_vals'><a class='stability Unmarked' title='No stability level'></a><code>possible_vals</code></td><td><div class='docblock'><p>A list of possible values for an option or positional argument</p>
</div></td></tr><tr><td id='structfield.requires'><a class='stability Unmarked' title='No stability level'></a><code>requires</code></td><td><div class='docblock'><p>A list of names of other arguments that are <em>required</em> to be used when
this flag is used</p>
</div></td></tr></table><h2 id='methods'>Methods</h2><h3 class='impl'><a class='stability Unmarked' title='No stability level'></a><code>impl&lt;'n, 'l, 'h, 'b, 'p, 'r&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>&lt;'n, 'l, 'h, 'b, 'p, 'r&gt;</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;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>&lt;'n, 'l, 'h, 'b, 'p, 'r&gt;</code></h4>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><a class='stability Unmarked' title='No stability level'></a><code>impl&lt;'n, 'l, 'h, 'b, 'p, 'r&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>&lt;'n, 'l, 'h, 'b, 'p, 'r&gt;</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;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>&lt;'n, 'l, 'h, 'b, 'p, 'r&gt;</code></h4>
<div class='docblock'><p>Creates a new instace of <code>Arg</code> using a unique string name.
The name will be used by the library consumer to get information about
whether or not the argument was used at runtime. </p>

View file

@ -43,18 +43,11 @@
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>ArgMatches</a><wbr></span><span class='out-of-band'><span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-8951' 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#57-68'>[src]</a></span></h1>
<pre class='rust struct'>pub struct ArgMatches&lt;'a&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;'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, FlagArg&gt;,
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>&lt;&amp;'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, OptArg&gt;,
pub positionals: <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;'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, PosArg&gt;,
pub subcommand: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='http://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html' title='alloc::boxed::Box'>Box</a>&lt;<a class='struct' href='../clap/struct.SubCommand.html' title='clap::SubCommand'>SubCommand</a>&lt;'a&gt;&gt;&gt;,
pub usage: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='http://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a>&gt;,
}</pre><div class='docblock'><p>Used to get information about the arguments that
where supplied to the program at runtime.</p>
<p>Fields of <code>ArgMatches</code> aren&#39;t designed to be used directly, only
the methods in order to query information.</p>
// some fields omitted
}</pre><div class='docblock'><p>Used to get information about the arguments that where supplied to the program at runtime by
the user. To get a new instance of this struct you use <code>.get_matches()</code> of the <code>App</code> struct.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
@ -66,19 +59,17 @@ the methods in order to query information.</p>
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Value for output: {}&quot;</span>, <span class='ident'>o</span>);
}
<span class='comment'>// Although not advised, if you have a required argument</span>
<span class='comment'>// you can call .unwrap() because the program will exit long before</span>
<span class='comment'>// here at noticing the user didn&#39;t supply a required argument...</span>
<span class='comment'>// use at your own risk ;)</span>
<span class='comment'>// If you have a required argument you can call .unwrap() because the program will exit long</span>
<span class='comment'>// before this point if the user didn&#39;t specify it at runtime.</span>
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Config file: {}&quot;</span>, <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;config&quot;</span>).<span class='ident'>unwrap</span>());
<span class='comment'>// You can check the present of an argument</span>
<span class='comment'>// You can check the presence of an argument</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>is_present</span>(<span class='string'>&quot;debug&quot;</span>) {
<span class='comment'>// Checking if &quot;debug&quot; was present was necessary,</span>
<span class='comment'>// as occurrences returns 0 if a flag isn&#39;t found</span>
<span class='comment'>// but we can check how many times &quot;debug&quot; was found</span>
<span class='comment'>// if we allow multiple (if multiple isn&#39;t allowed it always be 1 or 0)</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>&quot;debug&quot;</span>) <span class='op'>&gt;</span> <span class='number'>1</span> {
<span class='comment'>// Another way to check if an argument was present, or if it occurred multiple times is to</span>
<span class='comment'>// use occurrences_of() which returns 0 if an argument isn&#39;t found at runtime, or the</span>
<span class='comment'>// number of times that it occurred, if it was. To allow an argument to appear more than</span>
<span class='comment'>// once, you must use the .multiple(true) method, otherwise it will only return 1 or 0.</span>
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>&quot;debug&quot;</span>) <span class='op'>&gt;</span> <span class='number'>2</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is REALLY on&quot;</span>);
} <span class='kw'>else</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode kind of on&quot;</span>);
@ -95,16 +86,7 @@ the methods in order to query information.</p>
}
}
</pre>
</div><h2 class='fields'>Fields</h2>
<table><tr><td id='structfield.flags'><a class='stability Unmarked' title='No stability level'></a><code>flags</code></td><td></td></tr><tr><td id='structfield.opts'><a class='stability Unmarked' title='No stability level'></a><code>opts</code></td><td></td></tr><tr><td id='structfield.positionals'><a class='stability Unmarked' title='No stability level'></a><code>positionals</code></td><td></td></tr><tr><td id='structfield.subcommand'><a class='stability Unmarked' title='No stability level'></a><code>subcommand</code></td><td></td></tr><tr><td id='structfield.usage'><a class='stability Unmarked' title='No stability level'></a><code>usage</code></td><td></td></tr></table><h2 id='methods'>Methods</h2><h3 class='impl'><a class='stability Unmarked' title='No stability level'></a><code>impl&lt;'a&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;</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>() -&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;</code></h4>
<div class='docblock'><p>Creates a new instance of <code>ArgMatches</code>. This ins&#39;t called directly, but
through the <code>.get_matches()</code> method of <code>App</code></p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
<span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;myprog&quot;</span>).<span class='ident'>get_matches</span>();
</pre>
</div><h4 id='method.value_of' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.value_of' class='fnname'>value_of</a>&lt;'n&gt;(&amp;self, name: &amp;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;</code></h4>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><a class='stability Unmarked' title='No stability level'></a><code>impl&lt;'a&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;</code></h3><div class='impl-items'><h4 id='method.value_of' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.value_of' class='fnname'>value_of</a>&lt;'n&gt;(&amp;self, name: &amp;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;</code></h4>
<div class='docblock'><p>Gets the value of a specific option or positional argument (i.e. an argument that takes
an additional value at runtime). If the option wasn&#39;t present at runtime
it returns <code>None</code>. </p>
@ -120,7 +102,7 @@ prefer <code>values_of()</code> as <code>value_of()</code> will only return the
</pre>
</div><h4 id='method.values_of' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.values_of' class='fnname'>values_of</a>&lt;'n&gt;(&amp;self, name: &amp;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;&gt;</code></h4>
<div class='docblock'><p>Gets the values of a specific option or positional argument in a vector (i.e. an argument
that takes an additional value at runtime). If the option wasn&#39;t present at runtime it
that takes multiple values at runtime). If the option wasn&#39;t present at runtime it
returns <code>None</code></p>
<h1 id="example" class='section-header'><a
@ -135,8 +117,7 @@ returns <code>None</code></p>
}
</pre>
</div><h4 id='method.is_present' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.is_present' class='fnname'>is_present</a>&lt;'n&gt;(&amp;self, name: &amp;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>Checks if a flag was argument was supplied at runtime. <strong>DOES NOT</strong> work for
option or positional arguments (use <code>.value_of()</code> instead)</p>
<div class='docblock'><p>Returns if an argument was present at runtime.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
@ -145,10 +126,9 @@ option or positional arguments (use <code>.value_of()</code> instead)</p>
}
</pre>
</div><h4 id='method.occurrences_of' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.occurrences_of' class='fnname'>occurrences_of</a>&lt;'n&gt;(&amp;self, name: &amp;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a href='http://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a></code></h4>
<div class='docblock'><p>Checks the number of occurrences of an option, flag, or positional argument at runtime.
If an option or flag isn&#39;t present it will return <code>0</code>, if the option or flag doesn&#39;t
allow multiple occurrences, it will return <code>1</code> no matter how many times it occurred
(unless it wasn&#39;t prsent) at all.</p>
<div class='docblock'><p>Returns the number of occurrences of an option, flag, or positional argument at runtime.
If an argument isn&#39;t present it will return <code>0</code>. Can be used on arguments which <em>don&#39;t</em>
allow multiple occurrences, but will obviously only return <code>0</code> or <code>1</code>.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
@ -159,7 +139,8 @@ allow multiple occurrences, it will return <code>1</code> no matter how many tim
}
</pre>
</div><h4 id='method.subcommand_matches' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.subcommand_matches' class='fnname'>subcommand_matches</a>&lt;'n&gt;(&amp;self, name: &amp;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;<a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&gt;</code></h4>
<div class='docblock'><p>If a subcommand was found, returns the ArgMatches struct associated with it&#39;s matches</p>
<div class='docblock'><p>Returns the <code>ArgMatches</code> for a particular subcommand or None if the subcommand wasn&#39;t
present at runtime.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
@ -168,7 +149,10 @@ allow multiple occurrences, it will return <code>1</code> no matter how many tim
}
</pre>
</div><h4 id='method.subcommand_name' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.subcommand_name' class='fnname'>subcommand_name</a>(&amp;self) -&gt; <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;</code></h4>
<div class='docblock'><p>If a subcommand was found, returns the name associated with it</p>
<div class='docblock'><p>Returns the name of the subcommand used of the parent <code>App</code>, or <code>None</code> if one wasn&#39;t found</p>
<p><em>NOTE</em>: Only a single subcommand may be present per <code>App</code> at runtime, does <em>NOT</em> check for
the name of sub-subcommand&#39;s names</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
@ -179,7 +163,8 @@ allow multiple occurrences, it will return <code>1</code> no matter how many tim
}
</pre>
</div><h4 id='method.subcommand' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.subcommand' class='fnname'>subcommand</a>(&amp;self) -&gt; <a href='http://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(&amp;<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;<a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&gt;)</a></code></h4>
<div class='docblock'><p>If a subcommand was found, returns the name and matches associated with it</p>
<div class='docblock'><p>Returns the name and <code>ArgMatches</code> of the subcommand used at runtime or (&quot;&quot;, None) if one
wasn&#39;t found.</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
@ -190,7 +175,7 @@ allow multiple occurrences, it will return <code>1</code> no matter how many tim
}
</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>(&amp;self) -&gt; &amp;<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 usage</p>
<div class='docblock'><p>Returns a string slice of the usage statement for the <code>App</code> (or <code>SubCommand</code>)</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>

File diff suppressed because one or more lines are too long

View file

@ -1285,6 +1285,22 @@
<span id="1243">1243</span>
<span id="1244">1244</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>
<span id="1261">1261</span>
</pre><pre class='rust '>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeMap</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeSet</span>;
@ -1390,7 +1406,7 @@
}
}
<span class='doccomment'>/// Sets a string of author(s)</span>
<span class='doccomment'>/// Sets a string of author(s) and will be showed to the user when displaying help inofrmation</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
@ -1405,7 +1421,8 @@
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets a string briefly describing what the program does</span>
<span class='doccomment'>/// Sets a string briefly describing what the program does and will be displayed when</span>
<span class='doccomment'>/// displaying help information.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
@ -1420,7 +1437,8 @@
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets a string of the version number</span>
<span class='doccomment'>/// Sets a string of the version number to be displayed when displaying version or help</span>
<span class='doccomment'>/// information.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
@ -1435,13 +1453,15 @@
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets a custom usage string to over-ride the one auto-generated by `clap`</span>
<span class='doccomment'>/// Sets a custom usage string to over-ride the one auto-generated by `clap`. Will be</span>
<span class='doccomment'>/// displayed to the user when errors are found in argument parsing, or when you call</span>
<span class='doccomment'>/// `.usage()` of `ArgMatches`</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// *NOTE:* You do not need to specify the &quot;USAGE: &quot; portion, as that will </span>
<span class='doccomment'>/// *NOTE:* You do not need to specify the &quot;USAGE: \n\t&quot; portion, as that will </span>
<span class='doccomment'>/// still be applied by `clap`, you only need to specify the portion starting</span>
<span class='doccomment'>/// with the binary name. </span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// *NOTE:* This will not replace the entire help message, only the portion</span>
<span class='doccomment'>/// *NOTE:* This will not replace the entire help message, *only* the portion</span>
<span class='doccomment'>/// showing the usage.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
@ -1644,10 +1664,10 @@
<span class='self'>self</span>
}
<span class='doccomment'>/// Adds a subcommand to the list of valid possibilties. Subcommands</span>
<span class='doccomment'>/// are effectively sub apps, because they can contain their own arguments</span>
<span class='doccomment'>/// and subcommands. They also function just like apps, in that they get their</span>
<span class='doccomment'>/// own auto generated help and version switches.</span>
<span class='doccomment'>/// Adds a subcommand to the list of valid possibilties. Subcommands are effectively sub apps,</span>
<span class='doccomment'>/// because they can contain their own arguments, subcommands, version, usage, etc. They also</span>
<span class='doccomment'>/// function just like apps, in that they get their own auto generated help and version</span>
<span class='doccomment'>/// switches.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
@ -1688,6 +1708,9 @@
<span class='self'>self</span>
}
<span class='comment'>// Creates a usage string if one was not provided by the user manually. This happens just</span>
<span class='comment'>// after all arguments were parsed, but before any subcommands have been parsed (so as to</span>
<span class='comment'>// give subcommands their own usage recursively)</span>
<span class='kw'>fn</span> <span class='ident'>create_usage</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>String</span> {
<span class='kw'>let</span> <span class='ident'>tab</span> <span class='op'>=</span> <span class='string'>&quot; &quot;</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>usage</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>75</span>);
@ -1776,6 +1799,7 @@
<span class='ident'>usage</span>
}
<span class='comment'>// Prints the usage statement to the user</span>
<span class='kw'>fn</span> <span class='ident'>print_usage</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>more_info</span>: <span class='ident'>bool</span>) {
<span class='macro'>print</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>,<span class='self'>self</span>.<span class='ident'>create_usage</span>());
<span class='kw'>if</span> <span class='ident'>more_info</span> {
@ -1783,6 +1807,7 @@
}
}
<span class='comment'>// Prints the full help message to the user</span>
<span class='kw'>fn</span> <span class='ident'>print_help</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) {
<span class='self'>self</span>.<span class='ident'>print_version</span>(<span class='boolval'>false</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>();
@ -1907,6 +1932,7 @@
<span class='self'>self</span>.<span class='ident'>exit</span>(<span class='number'>0</span>);
}
<span class='comment'>// Used when spacing arguments and their help message when displaying help information</span>
<span class='attribute'>#[<span class='ident'>inline</span>(<span class='ident'>always</span>)]</span>
<span class='kw'>fn</span> <span class='ident'>get_spaces</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>num</span>: <span class='ident'>usize</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span> {
<span class='kw'>match</span> <span class='ident'>num</span> {
@ -1944,6 +1970,7 @@
}
}
<span class='comment'>// Prints the version to the user and exits if quit=true</span>
<span class='kw'>fn</span> <span class='ident'>print_version</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>quit</span>: <span class='ident'>bool</span>) {
<span class='comment'>// Print the binary name if existing, but replace all spaces with hyphens in case we&#39;re</span>
<span class='comment'>// dealing with subcommands i.e. git mv is translated to git-mv</span>
@ -1951,16 +1978,21 @@
<span class='kw'>if</span> <span class='ident'>quit</span> { <span class='self'>self</span>.<span class='ident'>exit</span>(<span class='number'>0</span>); }
}
<span class='comment'>// Exits with a status code passed to the OS</span>
<span class='comment'>// This is legacy from before std::process::exit() and may be removed evenutally</span>
<span class='kw'>fn</span> <span class='ident'>exit</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>status</span>: <span class='ident'>i32</span>) {
<span class='ident'>process</span>::<span class='ident'>exit</span>(<span class='ident'>status</span>);
}
<span class='comment'>// Reports and error to the users screen along with an optional usage statement and quits</span>
<span class='kw'>fn</span> <span class='ident'>report_error</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>msg</span>: <span class='ident'>String</span>, <span class='ident'>usage</span>: <span class='ident'>bool</span>, <span class='ident'>quit</span>: <span class='ident'>bool</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>msg</span>);
<span class='kw'>if</span> <span class='ident'>usage</span> { <span class='self'>self</span>.<span class='ident'>print_usage</span>(<span class='boolval'>true</span>); }
<span class='kw'>if</span> <span class='ident'>quit</span> { <span class='self'>self</span>.<span class='ident'>exit</span>(<span class='number'>1</span>); }
}
<span class='comment'>// Starts the parsing process. Called on top level parent app **ONLY** then recursively calls</span>
<span class='comment'>// the real parsing function for subcommands</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_matches</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>ArgMatches</span><span class='op'>&lt;</span><span class='lifetime'>&#39;ar</span><span class='op'>&gt;</span> {
<span class='self'>self</span>.<span class='ident'>verify_positionals</span>();
<span class='kw'>for</span> (_,<span class='ident'>sc</span>) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>subcommands</span>.<span class='ident'>iter_mut</span>() {
@ -1983,7 +2015,7 @@
<span class='ident'>matches</span>
}
<span class='kw'>fn</span> <span class='ident'>verify_positionals</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>) {
<span class='comment'>// Because you must wait until all arguments have been supplied, this is the first chance</span>
<span class='comment'>// to make assertions on positional argument indexes</span>

View file

@ -400,14 +400,25 @@
<span id="358">358</span>
<span id="359">359</span>
<span id="360">360</span>
<span id="361">361</span>
<span id="362">362</span>
<span id="363">363</span>
<span id="364">364</span>
<span id="365">365</span>
<span id="366">366</span>
<span id="367">367</span>
<span id="368">368</span>
<span id="369">369</span>
<span id="370">370</span>
<span id="371">371</span>
</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'>/// Used to set all the options and relationships that define a valid argument for the program.</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// This struct is used by the library consumer and describes the command line arguments for </span>
<span class='doccomment'>/// their program.</span>
<span class='doccomment'>/// and then evaluates the settings the consumer provided and determines the concret</span>
<span class='doccomment'>/// argument struct to use when parsing.</span>
<span class='doccomment'>/// their program. Then evaluates the settings the consumer provided and determines the concret</span>
<span class='doccomment'>/// argument type to use when parsing.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
@ -423,37 +434,48 @@
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Arg</span><span class='op'>&lt;</span><span class='lifetime'>&#39;n</span>, <span class='lifetime'>&#39;l</span>, <span class='lifetime'>&#39;h</span>, <span class='lifetime'>&#39;b</span>, <span class='lifetime'>&#39;p</span>, <span class='lifetime'>&#39;r</span><span class='op'>&gt;</span> {
<span class='doccomment'>/// The unique name of the argument, required</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;n</span> <span class='ident'>str</span>,
<span class='doccomment'>/// The short version (i.e. single character) of the argument, no preceding `-`</span>
<span class='doccomment'>/// **NOTE:** `short` is mutually exclusive with `index`</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>short</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>char</span><span class='op'>&gt;</span>,
<span class='doccomment'>/// The long version of the flag (i.e. word) without the preceding `--`</span>
<span class='doccomment'>/// **NOTE:** `long` is mutually exclusive with `index`</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>long</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;l</span> <span class='ident'>str</span><span class='op'>&gt;</span>,
<span class='doccomment'>/// The string of text that will displayed to the user when the application&#39;s</span>
<span class='doccomment'>/// `help` text is displayed</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>help</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;h</span> <span class='ident'>str</span><span class='op'>&gt;</span>,
<span class='doccomment'>/// If this is a required by default when using the command line program</span>
<span class='doccomment'>/// i.e. a configuration file that&#39;s required for the program to function</span>
<span class='doccomment'>/// **NOTE:** required by default means, it is required *until* mutually</span>
<span class='doccomment'>/// exclusive arguments are evaluated.</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>required</span>: <span class='ident'>bool</span>,
<span class='doccomment'>/// Determines if this argument is an option, vice a flag or positional and</span>
<span class='doccomment'>/// is mutually exclusive with `index` and `multiple`</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>takes_value</span>: <span class='ident'>bool</span>,
<span class='doccomment'>/// The index of the argument. `index` is mutually exclusive with `takes_value`</span>
<span class='doccomment'>/// and `multiple`</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>index</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>u8</span><span class='op'>&gt;</span>,
<span class='doccomment'>/// Determines if multiple instances of the same flag are allowed. `multiple` </span>
<span class='doccomment'>/// is mutually exclusive with `index` and `takes_value`.</span>
<span class='doccomment'>/// I.e. `-v -v -v` or `-vvv`</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>multiple</span>: <span class='ident'>bool</span>,
<span class='doccomment'>/// A list of names for other arguments that *may not* be used with this flag</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>blacklist</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;b</span> <span class='ident'>str</span><span class='op'>&gt;&gt;</span>,
<span class='doccomment'>/// A list of possible values for an option or positional argument</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>possible_vals</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;p</span> <span class='ident'>str</span><span class='op'>&gt;&gt;</span>,
<span class='doccomment'>/// A list of names of other arguments that are *required* to be used when </span>
<span class='doccomment'>/// this flag is used</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>requires</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;r</span> <span class='ident'>str</span><span class='op'>&gt;&gt;</span>
}

View file

@ -327,6 +327,9 @@
<span id="285">285</span>
<span id="286">286</span>
<span id="287">287</span>
<span id="288">288</span>
<span id="289">289</span>
<span id="290">290</span>
</pre><pre class='rust '>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
@ -335,13 +338,10 @@
<span class='kw'>use</span> <span class='ident'>args</span>::<span class='ident'>optarg</span>::<span class='ident'>OptArg</span>;
<span class='kw'>use</span> <span class='ident'>args</span>::<span class='ident'>posarg</span>::<span class='ident'>PosArg</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'>/// Used to get information about the arguments that where supplied to the program at runtime by</span>
<span class='doccomment'>/// the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Fields of `ArgMatches` aren&#39;t designed to be used directly, only </span>
<span class='doccomment'>/// the methods in order to query information.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
@ -361,19 +361,17 @@
<span class='doccomment'>/// println!(&quot;Value for output: {}&quot;, o);</span>
<span class='doccomment'>/// }</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// // Although not advised, if you have a required argument</span>
<span class='doccomment'>/// // you can call .unwrap() because the program will exit long before</span>
<span class='doccomment'>/// // here at noticing the user didn&#39;t supply a required argument...</span>
<span class='doccomment'>/// // use at your own risk ;)</span>
<span class='doccomment'>/// // If you have a required argument you can call .unwrap() because the program will exit long</span>
<span class='doccomment'>/// // before this point if the user didn&#39;t specify it at runtime.</span>
<span class='doccomment'>/// println!(&quot;Config file: {}&quot;, matches.value_of(&quot;config&quot;).unwrap());</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// // You can check the present of an argument</span>
<span class='doccomment'>/// // You can check the presence of an argument</span>
<span class='doccomment'>/// if matches.is_present(&quot;debug&quot;) {</span>
<span class='doccomment'>/// // Checking if &quot;debug&quot; was present was necessary,</span>
<span class='doccomment'>/// // as occurrences returns 0 if a flag isn&#39;t found</span>
<span class='doccomment'>/// // but we can check how many times &quot;debug&quot; was found</span>
<span class='doccomment'>/// // if we allow multiple (if multiple isn&#39;t allowed it always be 1 or 0)</span>
<span class='doccomment'>/// if matches.occurrences_of(&quot;debug&quot;) &gt; 1 {</span>
<span class='doccomment'>/// // Another way to check if an argument was present, or if it occurred multiple times is to</span>
<span class='doccomment'>/// // use occurrences_of() which returns 0 if an argument isn&#39;t found at runtime, or the</span>
<span class='doccomment'>/// // number of times that it occurred, if it was. To allow an argument to appear more than</span>
<span class='doccomment'>/// // once, you must use the .multiple(true) method, otherwise it will only return 1 or 0.</span>
<span class='doccomment'>/// if matches.occurrences_of(&quot;debug&quot;) &gt; 2 {</span>
<span class='doccomment'>/// println!(&quot;Debug mode is REALLY on&quot;);</span>
<span class='doccomment'>/// } else {</span>
<span class='doccomment'>/// println!(&quot;Debug mode kind of on&quot;);</span>
@ -390,11 +388,15 @@
<span class='doccomment'>/// }</span>
<span class='doccomment'>/// }</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ArgMatches</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span><span class='op'>&gt;</span> {
<span class='comment'>// pub matches_of: &amp;&#39;static str,</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</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;a</span> <span class='ident'>str</span>, <span class='ident'>FlagArg</span><span class='op'>&gt;</span>,
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</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;a</span> <span class='ident'>str</span>, <span class='ident'>OptArg</span><span class='op'>&gt;</span>,
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>positionals</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;a</span> <span class='ident'>str</span>, <span class='ident'>PosArg</span><span class='op'>&gt;</span>,
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>subcommand</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>Box</span><span class='op'>&lt;</span><span class='ident'>SubCommand</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span><span class='op'>&gt;&gt;</span><span class='op'>&gt;</span>,
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='ident'>usage</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>String</span><span class='op'>&gt;</span>
}
@ -408,6 +410,7 @@
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// let matches = App::new(&quot;myprog&quot;).get_matches();</span>
<span class='doccomment'>/// ```</span>
<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-&gt;</span> <span class='ident'>ArgMatches</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span><span class='op'>&gt;</span> {
<span class='ident'>ArgMatches</span> {
<span class='comment'>// matches_of: name,</span>
@ -450,7 +453,7 @@
}
<span class='doccomment'>/// Gets the values of a specific option or positional argument in a vector (i.e. an argument</span>
<span class='doccomment'>/// that takes an additional value at runtime). If the option wasn&#39;t present at runtime it</span>
<span class='doccomment'>/// that takes multiple values at runtime). If the option wasn&#39;t present at runtime it</span>
<span class='doccomment'>/// returns `None`</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
@ -481,8 +484,7 @@
<span class='prelude-val'>None</span>
}
<span class='doccomment'>/// Checks if a flag was argument was supplied at runtime. **DOES NOT** work for</span>
<span class='doccomment'>/// option or positional arguments (use `.value_of()` instead)</span>
<span class='doccomment'>/// Returns if an argument was present at runtime. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
@ -504,10 +506,9 @@
<span class='boolval'>false</span>
}
<span class='doccomment'>/// Checks the number of occurrences of an option, flag, or positional argument at runtime. </span>
<span class='doccomment'>/// If an option or flag isn&#39;t present it will return `0`, if the option or flag doesn&#39;t </span>
<span class='doccomment'>/// allow multiple occurrences, it will return `1` no matter how many times it occurred </span>
<span class='doccomment'>/// (unless it wasn&#39;t prsent) at all.</span>
<span class='doccomment'>/// Returns the number of occurrences of an option, flag, or positional argument at runtime. </span>
<span class='doccomment'>/// If an argument isn&#39;t present it will return `0`. Can be used on arguments which *don&#39;t*</span>
<span class='doccomment'>/// allow multiple occurrences, but will obviously only return `0` or `1`.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
@ -534,7 +535,8 @@
<span class='number'>0</span>
}
<span class='doccomment'>/// If a subcommand was found, returns the ArgMatches struct associated with it&#39;s matches</span>
<span class='doccomment'>/// Returns the `ArgMatches` for a particular subcommand or None if the subcommand wasn&#39;t</span>
<span class='doccomment'>/// present at runtime.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
@ -554,7 +556,10 @@
<span class='prelude-val'>None</span>
}
<span class='doccomment'>/// If a subcommand was found, returns the name associated with it</span>
<span class='doccomment'>/// Returns the name of the subcommand used of the parent `App`, or `None` if one wasn&#39;t found</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// *NOTE*: Only a single subcommand may be present per `App` at runtime, does *NOT* check for</span>
<span class='doccomment'>/// the name of sub-subcommand&#39;s names</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
@ -575,7 +580,8 @@
<span class='prelude-val'>None</span>
}
<span class='doccomment'>/// If a subcommand was found, returns the name and matches associated with it</span>
<span class='doccomment'>/// Returns the name and `ArgMatches` of the subcommand used at runtime or (&quot;&quot;, None) if one</span>
<span class='doccomment'>/// wasn&#39;t found.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
@ -596,7 +602,7 @@
(<span class='string'>&quot;&quot;</span>, <span class='prelude-val'>None</span>)
}
<span class='doccomment'>/// Returns a slice of the usage</span>
<span class='doccomment'>/// Returns a string slice of the usage statement for the `App` (or `SubCommand`)</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>

View file

@ -102,7 +102,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
}
}
/// Sets a string of author(s)
/// Sets a string of author(s) and will be showed to the user when displaying help inofrmation
///
/// # Example
///
@ -117,7 +117,8 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
self
}
/// Sets a string briefly describing what the program does
/// Sets a string briefly describing what the program does and will be displayed when
/// displaying help information.
///
/// # Example
///
@ -132,7 +133,8 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
self
}
/// Sets a string of the version number
/// Sets a string of the version number to be displayed when displaying version or help
/// information.
///
/// # Example
///
@ -147,13 +149,15 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
self
}
/// Sets a custom usage string to over-ride the one auto-generated by `clap`
/// Sets a custom usage string to over-ride the one auto-generated by `clap`. Will be
/// displayed to the user when errors are found in argument parsing, or when you call
/// `.usage()` of `ArgMatches`
///
/// *NOTE:* You do not need to specify the "USAGE: " portion, as that will
/// *NOTE:* You do not need to specify the "USAGE: \n\t" portion, as that will
/// still be applied by `clap`, you only need to specify the portion starting
/// with the binary name.
///
/// *NOTE:* This will not replace the entire help message, only the portion
/// *NOTE:* This will not replace the entire help message, *only* the portion
/// showing the usage.
///
/// # Example
@ -356,10 +360,10 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
self
}
/// Adds a subcommand to the list of valid possibilties. Subcommands
/// are effectively sub apps, because they can contain their own arguments
/// and subcommands. They also function just like apps, in that they get their
/// own auto generated help and version switches.
/// Adds a subcommand to the list of valid possibilties. Subcommands are effectively sub apps,
/// because they can contain their own arguments, subcommands, version, usage, etc. They also
/// function just like apps, in that they get their own auto generated help and version
/// switches.
///
/// # Example
///
@ -400,6 +404,9 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
self
}
// Creates a usage string if one was not provided by the user manually. This happens just
// after all arguments were parsed, but before any subcommands have been parsed (so as to
// give subcommands their own usage recursively)
fn create_usage(&self) -> String {
let tab = " ";
let mut usage = String::with_capacity(75);
@ -488,6 +495,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
usage
}
// Prints the usage statement to the user
fn print_usage(&self, more_info: bool) {
print!("{}",self.create_usage());
if more_info {
@ -495,6 +503,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
}
}
// Prints the full help message to the user
fn print_help(&self) {
self.print_version(false);
let flags = !self.flags.is_empty();
@ -619,6 +628,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
self.exit(0);
}
// Used when spacing arguments and their help message when displaying help information
#[inline(always)]
fn get_spaces(&self, num: usize) -> &'static str {
match num {
@ -656,6 +666,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
}
}
// Prints the version to the user and exits if quit=true
fn print_version(&self, quit: bool) {
// Print the binary name if existing, but replace all spaces with hyphens in case we're
// dealing with subcommands i.e. git mv is translated to git-mv
@ -663,16 +674,21 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
if quit { self.exit(0); }
}
// Exits with a status code passed to the OS
// This is legacy from before std::process::exit() and may be removed evenutally
fn exit(&self, status: i32) {
process::exit(status);
}
// Reports and error to the users screen along with an optional usage statement and quits
fn report_error(&self, msg: String, usage: bool, quit: bool) {
println!("{}", msg);
if usage { self.print_usage(true); }
if quit { self.exit(1); }
}
// Starts the parsing process. Called on top level parent app **ONLY** then recursively calls
// the real parsing function for subcommands
pub fn get_matches(mut self) -> ArgMatches<'ar> {
self.verify_positionals();
for (_,sc) in self.subcommands.iter_mut() {
@ -695,7 +711,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
matches
}
fn verify_positionals(&mut self) {
// Because you must wait until all arguments have been supplied, this is the first chance
// to make assertions on positional argument indexes

View file

@ -1,10 +1,10 @@
/// The abstract representation of a command line argument used by the consumer of the library.
/// Used to set all the options and relationships that define a valid argument for the program.
///
///
/// This struct is used by the library consumer and describes the command line arguments for
/// their program.
/// and then evaluates the settings the consumer provided and determines the concret
/// argument struct to use when parsing.
/// their program. Then evaluates the settings the consumer provided and determines the concret
/// argument type to use when parsing.
///
/// # Example
///
@ -20,37 +20,48 @@
/// # ).get_matches();
pub struct Arg<'n, 'l, 'h, 'b, 'p, 'r> {
/// The unique name of the argument, required
#[doc(hidden)]
pub name: &'n str,
/// The short version (i.e. single character) of the argument, no preceding `-`
/// **NOTE:** `short` is mutually exclusive with `index`
#[doc(hidden)]
pub short: Option<char>,
/// The long version of the flag (i.e. word) without the preceding `--`
/// **NOTE:** `long` is mutually exclusive with `index`
#[doc(hidden)]
pub long: Option<&'l str>,
/// The string of text that will displayed to the user when the application's
/// `help` text is displayed
#[doc(hidden)]
pub help: Option<&'h str>,
/// If this is a required by default when using the command line program
/// i.e. a configuration file that's required for the program to function
/// **NOTE:** required by default means, it is required *until* mutually
/// exclusive arguments are evaluated.
#[doc(hidden)]
pub required: bool,
/// Determines if this argument is an option, vice a flag or positional and
/// is mutually exclusive with `index` and `multiple`
#[doc(hidden)]
pub takes_value: bool,
/// The index of the argument. `index` is mutually exclusive with `takes_value`
/// and `multiple`
#[doc(hidden)]
pub index: Option<u8>,
/// Determines if multiple instances of the same flag are allowed. `multiple`
/// is mutually exclusive with `index` and `takes_value`.
/// I.e. `-v -v -v` or `-vvv`
#[doc(hidden)]
pub multiple: bool,
/// A list of names for other arguments that *may not* be used with this flag
#[doc(hidden)]
pub blacklist: Option<Vec<&'b str>>,
/// A list of possible values for an option or positional argument
#[doc(hidden)]
pub possible_vals: Option<Vec<&'p str>>,
/// A list of names of other arguments that are *required* to be used when
/// this flag is used
#[doc(hidden)]
pub requires: Option<Vec<&'r str>>
}

View file

@ -5,13 +5,10 @@ use args::flagarg::FlagArg;
use args::optarg::OptArg;
use args::posarg::PosArg;
/// Used to get information about the arguments that
/// where supplied to the program at runtime.
/// Used to get information about the arguments that where supplied to the program at runtime by
/// the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct.
///
///
/// Fields of `ArgMatches` aren't designed to be used directly, only
/// the methods in order to query information.
///
/// # Example
///
/// ```no_run
@ -31,19 +28,17 @@ use args::posarg::PosArg;
/// println!("Value for output: {}", o);
/// }
///
/// // Although not advised, if you have a required argument
/// // you can call .unwrap() because the program will exit long before
/// // here at noticing the user didn't supply a required argument...
/// // use at your own risk ;)
/// // If you have a required argument you can call .unwrap() because the program will exit long
/// // before this point if the user didn't specify it at runtime.
/// println!("Config file: {}", matches.value_of("config").unwrap());
///
/// // You can check the present of an argument
/// // You can check the presence of an argument
/// if matches.is_present("debug") {
/// // Checking if "debug" was present was necessary,
/// // as occurrences returns 0 if a flag isn't found
/// // but we can check how many times "debug" was found
/// // if we allow multiple (if multiple isn't allowed it always be 1 or 0)
/// if matches.occurrences_of("debug") > 1 {
/// // Another way to check if an argument was present, or if it occurred multiple times is to
/// // use occurrences_of() which returns 0 if an argument isn't found at runtime, or the
/// // number of times that it occurred, if it was. To allow an argument to appear more than
/// // once, you must use the .multiple(true) method, otherwise it will only return 1 or 0.
/// if matches.occurrences_of("debug") > 2 {
/// println!("Debug mode is REALLY on");
/// } else {
/// println!("Debug mode kind of on");
@ -60,11 +55,15 @@ use args::posarg::PosArg;
/// }
/// }
pub struct ArgMatches<'a> {
// pub matches_of: &'static str,
#[doc(hidden)]
pub flags: HashMap<&'a str, FlagArg>,
#[doc(hidden)]
pub opts: HashMap<&'a str, OptArg>,
#[doc(hidden)]
pub positionals: HashMap<&'a str, PosArg>,
#[doc(hidden)]
pub subcommand: Option<Box<SubCommand<'a>>>,
#[doc(hidden)]
pub usage: Option<String>
}
@ -78,6 +77,7 @@ impl<'a> ArgMatches<'a> {
/// # use clap::{App, Arg};
/// let matches = App::new("myprog").get_matches();
/// ```
#[doc(hidden)]
pub fn new() -> ArgMatches<'a> {
ArgMatches {
// matches_of: name,
@ -120,7 +120,7 @@ impl<'a> ArgMatches<'a> {
}
/// Gets the values of a specific option or positional argument in a vector (i.e. an argument
/// that takes an additional value at runtime). If the option wasn't present at runtime it
/// that takes multiple values at runtime). If the option wasn't present at runtime it
/// returns `None`
///
/// # Example
@ -151,8 +151,7 @@ impl<'a> ArgMatches<'a> {
None
}
/// Checks if a flag was argument was supplied at runtime. **DOES NOT** work for
/// option or positional arguments (use `.value_of()` instead)
/// Returns if an argument was present at runtime.
///
///
/// # Example
@ -174,10 +173,9 @@ impl<'a> ArgMatches<'a> {
false
}
/// Checks the number of occurrences of an option, flag, or positional argument at runtime.
/// If an option or flag isn't present it will return `0`, if the option or flag doesn't
/// allow multiple occurrences, it will return `1` no matter how many times it occurred
/// (unless it wasn't prsent) at all.
/// Returns the number of occurrences of an option, flag, or positional argument at runtime.
/// If an argument isn't present it will return `0`. Can be used on arguments which *don't*
/// allow multiple occurrences, but will obviously only return `0` or `1`.
///
///
/// # Example
@ -204,7 +202,8 @@ impl<'a> ArgMatches<'a> {
0
}
/// If a subcommand was found, returns the ArgMatches struct associated with it's matches
/// Returns the `ArgMatches` for a particular subcommand or None if the subcommand wasn't
/// present at runtime.
///
///
/// # Example
@ -224,7 +223,10 @@ impl<'a> ArgMatches<'a> {
None
}
/// If a subcommand was found, returns the name associated with it
/// Returns the name of the subcommand used of the parent `App`, or `None` if one wasn't found
///
/// *NOTE*: Only a single subcommand may be present per `App` at runtime, does *NOT* check for
/// the name of sub-subcommand's names
///
///
/// # Example
@ -245,7 +247,8 @@ impl<'a> ArgMatches<'a> {
None
}
/// If a subcommand was found, returns the name and matches associated with it
/// Returns the name and `ArgMatches` of the subcommand used at runtime or ("", None) if one
/// wasn't found.
///
///
/// # Example
@ -266,7 +269,7 @@ impl<'a> ArgMatches<'a> {
("", None)
}
/// Returns a slice of the usage
/// Returns a string slice of the usage statement for the `App` (or `SubCommand`)
///
///
/// # Example