Rebuild docs after tab->space change

This commit is contained in:
Kevin K 2015-03-16 14:48:25 -04:00
parent 20de5b339e
commit bc94d11b03
12 changed files with 1297 additions and 1297 deletions

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."]]});
initSidebarItems({"struct":[["App","Used to create a representation of the program and all possible command line arguments for parsing at runtime."]]});

View file

@ -45,95 +45,95 @@
<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>
<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>
<p>You can use <code>clap</code> to lay out a list of possible valid command line arguments and let <code>clap</code> parse the string given by the user at runtime.
When using <code>clap</code> you define a set of parameters and rules for your arguments and at runtime <code>clap</code> will determine their validity.
Also, <code>clap</code> provides the traditional version and help switches &#39;for free&#39; by parsing the list of possible valid arguments lazily at runtime.
i.e. only when it&#39;s been determined that the user wants or needs to see the help and version information.</p>
When using <code>clap</code> you define a set of parameters and rules for your arguments and at runtime <code>clap</code> will determine their validity.
Also, <code>clap</code> provides the traditional version and help switches &#39;for free&#39; by parsing the list of possible valid arguments lazily at runtime.
i.e. only when it&#39;s been determined that the user wants or needs to see the help and version information.</p>
<p>After defining a list of possible valid arguments you get a list of matches that the user supplied at runtime. You can then use this list to
determine the functioning of your program.</p>
determine the functioning of your program.</p>
<p># Example</p>
<pre id='rust-example-rendered' class='rust '>
<span class='kw'>use</span> <span class='ident'>clap</span>::{<span class='ident'>Arg</span>, <span class='ident'>App</span>, <span class='ident'>SubCommand</span>};
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
<span class='kw'>use</span> <span class='ident'>clap</span>::{<span class='ident'>Arg</span>, <span class='ident'>App</span>, <span class='ident'>SubCommand</span>};
<span class='comment'>// ...</span>
<span class='comment'>// ...</span>
<span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;MyApp&quot;</span>)
.<span class='ident'>version</span>(<span class='string'>&quot;1.0&quot;</span>)
.<span class='ident'>author</span>(<span class='string'>&quot;Kevin K. &lt;kbknapp@gmail.com&gt;&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Does awesome things&quot;</span>)
.<span class='ident'>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'>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'>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'>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'>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='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;MyApp&quot;</span>)
.<span class='ident'>version</span>(<span class='string'>&quot;1.0&quot;</span>)
.<span class='ident'>author</span>(<span class='string'>&quot;Kevin K. &lt;kbknapp@gmail.com&gt;&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Does awesome things&quot;</span>)
.<span class='ident'>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'>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'>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'>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'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;debug&quot;</span>)
.<span class='ident'>short</span>(<span class='string'>&quot;d&quot;</span>)
.<span class='ident'>multiple</span>(<span class='boolval'>true</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Turn debugging information on&quot;</span>))
.<span class='ident'>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'>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'>help</span>(<span class='string'>&quot;Display verbose information&quot;</span>)))
.<span class='ident'>get_matches</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'>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'>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'>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='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Value for output: {}&quot;</span>, <span class='ident'>o</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='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Value for output: {}&quot;</span>, <span class='ident'>o</span>);
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>c</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;config&quot;</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Value for config: {}&quot;</span>, <span class='ident'>c</span>);
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>c</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;config&quot;</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Value for config: {}&quot;</span>, <span class='ident'>c</span>);
}
<span class='kw'>match</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>&quot;debug&quot;</span>) {
<span class='kw'>match</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>&quot;debug&quot;</span>) {
<span class='number'>0</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is off&quot;</span>),
<span class='number'>1</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is kind of on&quot;</span>),
<span class='number'>2</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is on&quot;</span>),
<span class='number'>3</span> <span class='op'>|</span> _ <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Don&#39;t be crazy&quot;</span>),
}
<span class='number'>1</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is kind of on&quot;</span>),
<span class='number'>2</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is on&quot;</span>),
<span class='number'>3</span> <span class='op'>|</span> _ <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Don&#39;t be crazy&quot;</span>),
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>matches</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>subcommand_matches</span>(<span class='string'>&quot;test&quot;</span>) {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>matches</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>subcommand_matches</span>(<span class='string'>&quot;test&quot;</span>) {
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>is_present</span>(<span class='string'>&quot;verbose&quot;</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Printing verbose test info...&quot;</span>);
} <span class='kw'>else</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Not printing regular test info...&quot;</span>);
}
}
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Printing verbose test info...&quot;</span>);
} <span class='kw'>else</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Not printing regular test info...&quot;</span>);
}
}
<span class='comment'>// more porgram logic goes here...</span>
<span class='comment'>// more porgram logic goes here...</span>
</pre>
<p>If you were to compile the above program and run it with the flag <code>--help</code> or <code>-h</code> the following output woud be presented</p>
<pre><code class="language-sh"> $ myprog --help
MyApp 1.0
Kevin K. &lt;kbknapp@gmail.com&gt;
Does awesome things
<pre><code class="language-sh">$ myprog --help
MyApp 1.0
Kevin K. &lt;kbknapp@gmail.com&gt;
Does awesome things
USAGE:
USAGE:
MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]
FLAGS:
-d Turn debugging information on
-h,--help Prints this message
-v,--version Prints version information
FLAGS:
-d Turn debugging information on
-h,--help Prints this message
-v,--version Prints version information
OPTIONS:
OPTIONS:
-c,--config &lt;config&gt; Sets a custom config file
POSITIONAL ARGUMENTS:
output Sets an optional output file
POSITIONAL ARGUMENTS:
output Sets an optional output file
SUBCOMMANDS:
help Prints this message
test Has test sub-functionality
SUBCOMMANDS:
help Prints this message
test Has test sub-functionality
</code></pre>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
@ -141,7 +141,7 @@
<td><a class='stability Unmarked' title='No stability level'></a><a class='struct' href='struct.App.html'
title='clap::App'>App</a></td>
<td class='docblock short'><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>
</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. "],["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. "]]});

View file

@ -51,24 +51,24 @@
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
}</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>
<p>Stores a list of all posisble arguments, as well as information displayed to the user such as
help and versioning information.</p>
help and versioning information.</p>
<p># Example</p>
<pre id='rust-example-rendered' class='rust '>
<span class='kw'>let</span> <span class='ident'>myprog</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'>author</span>(<span class='string'>&quot;Me, me@mail.com&quot;</span>)
.<span class='ident'>version</span>(<span class='string'>&quot;1.0.2&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Explains in brief what the program does&quot;</span>)
.<span class='ident'>arg</span>(
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;in_file&quot;</span>).<span class='ident'>index</span>(<span class='number'>1</span>)
<span class='comment'>// Add other possible command line argument options here...</span>
)
.<span class='ident'>get_matches</span>();
<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'>myprog</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'>author</span>(<span class='string'>&quot;Me, me@mail.com&quot;</span>)
.<span class='ident'>version</span>(<span class='string'>&quot;1.0.2&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Explains in brief what the program does&quot;</span>)
.<span class='ident'>arg</span>(
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;in_file&quot;</span>).<span class='ident'>index</span>(<span class='number'>1</span>)
<span class='comment'>// Add other possible command line argument options here...</span>
)
.<span class='ident'>get_matches</span>();
<span class='comment'>// Your pogram logic starts here...</span>
<span class='comment'>// Your pogram logic starts here...</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 name displayed to the user when showing version and help/usage information</p>
@ -119,46 +119,46 @@ showing the usage.</p>
</div><h4 id='method.arg' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.arg' class='fnname'>arg</a>(self, a: <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Adds an argument to the list of valid possibilties</p>
<p># Example</p>
<pre id='rust-example-rendered' class='rust '>
.<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>)
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<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='comment'>// Additional argument configuration goes here...</span>
)
)
</pre>
</div><h4 id='method.args' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.args' class='fnname'>args</a>(self, args: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>&gt;) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Adds multiple arguments to the list of valid possibilties</p>
<p># Example</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>args</span>( <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;c&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;debug&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;d&quot;</span>)])
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<span class='ident'>args</span>( <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;c&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;debug&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;d&quot;</span>)])
</pre>
</div><h4 id='method.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>) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></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>
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>
<p># Example</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;config&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Controls configuration features&quot;</span>)
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config_file&quot;</span>)
.<span class='ident'>index</span>(<span class='number'>1</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Configuration file to use&quot;</span>)))
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;config&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Controls configuration features&quot;</span>)
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config_file&quot;</span>)
.<span class='ident'>index</span>(<span class='number'>1</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Configuration file to use&quot;</span>)))
<span class='comment'>// Additional subcommand configuration goes here, such as arguments...</span>
)
)
</pre>
</div><h4 id='method.subcommands' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.subcommands' class='fnname'>subcommands</a>(self, subcmds: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>&gt;) -&gt; <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
<div class='docblock'><p>Adds multiple subcommands to the list of valid possibilties</p>
<p># Example</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>subcommands</span>( <span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;config&quot;</span>).<span class='ident'>about</span>(<span class='string'>&quot;Controls configuration functionality&quot;</span>)
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config_file&quot;</span>).<span class='ident'>index</span>(<span class='number'>1</span>)),
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;debug&quot;</span>).<span class='ident'>about</span>(<span class='string'>&quot;Controls debug functionality&quot;</span>)])
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
.<span class='ident'>subcommands</span>( <span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;config&quot;</span>).<span class='ident'>about</span>(<span class='string'>&quot;Controls configuration functionality&quot;</span>)
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config_file&quot;</span>).<span class='ident'>index</span>(<span class='number'>1</span>)),
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;debug&quot;</span>).<span class='ident'>about</span>(<span class='string'>&quot;Controls debug functionality&quot;</span>)])
</pre>
</div><h4 id='method.get_matches' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.get_matches' class='fnname'>get_matches</a>(self) -&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a></code></h4>
</div></section>

View file

@ -170,16 +170,16 @@ arguments, they do not need to be set for each.</p>
</pre>
</div><h4 id='method.mutually_excludes_all' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.mutually_excludes_all' class='fnname'>mutually_excludes_all</a>(self, names: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets a mutually exclusive arguments by names. I.e. when using this argument,
the following argument can&#39;t be present.</p>
the following argument can&#39;t be present.</p>
<p><strong>NOTE:</strong> Mutually exclusive rules take precedence over being required
by default. Mutually exclusive rules only need to be set for one of the two
arguments, they do not need to be set for each.</p>
by default. Mutually exclusive rules only need to be set for one of the two
arguments, they do not need to be set for each.</p>
<p>Example:</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>mutually_excludes_all</span>(
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>&quot;debug&quot;</span>, <span class='string'>&quot;input&quot;</span>])
.<span class='ident'>mutually_excludes_all</span>(
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>&quot;debug&quot;</span>, <span class='string'>&quot;input&quot;</span>])
</pre>
</div><h4 id='method.requires' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.requires' class='fnname'>requires</a>(self, name: &amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets an argument by name that is required when this one is presnet I.e. when
@ -193,15 +193,15 @@ using this argument, the following argument <em>must</em> be present.</p>
</pre>
</div><h4 id='method.requires_all' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.requires_all' class='fnname'>requires_all</a>(self, names: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;&amp;'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Sets arguments by names that are required when this one is presnet I.e. when
using this argument, the following arguments <em>must</em> be present.</p>
using this argument, the following arguments <em>must</em> be present.</p>
<p><strong>NOTE:</strong> Mutually exclusive rules take precedence over being required
by default. </p>
by default. </p>
<p>Example:</p>
<pre id='rust-example-rendered' class='rust '>
.<span class='ident'>requires_all</span>(
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>&quot;debug&quot;</span>, <span class='string'>&quot;input&quot;</span>])
.<span class='ident'>requires_all</span>(
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>&quot;debug&quot;</span>, <span class='string'>&quot;input&quot;</span>])
</pre>
</div><h4 id='method.takes_value' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.takes_value' class='fnname'>takes_value</a>(self, tv: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
<div class='docblock'><p>Specifies that the argument takes an additional value at run time.</p>

View file

@ -50,16 +50,16 @@
}</pre><div class='docblock'><p>The abstract representation of a command line subcommand used by the consumer of the library.</p>
<p>This struct is used by the library consumer and describes all the valid options of the subcommand for
their program. SubCommands are treated like &quot;sub apps&quot; and contain all the same possibilities (such as
their own arguments and subcommands).</p>
their program. SubCommands are treated like &quot;sub apps&quot; and contain all the same possibilities (such as
their own arguments and subcommands).</p>
<p># Example</p>
<pre id='rust-example-rendered' class='rust '>
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;conifg&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Used for configuration&quot;</span>)
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config_file&quot;</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;The configuration file to use&quot;</span>)
.<span class='ident'>index</span>(<span class='number'>1</span>))
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>&quot;conifg&quot;</span>)
.<span class='ident'>about</span>(<span class='string'>&quot;Used for configuration&quot;</span>)
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;config_file&quot;</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;The configuration file to use&quot;</span>)
.<span class='ident'>index</span>(<span class='number'>1</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></td></tr><tr><td id='structfield.matches'><a class='stability Unmarked' title='No stability level'></a><code>matches</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 <a class='struct' href='../clap/struct.SubCommand.html' title='clap::SubCommand'>SubCommand</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>(name: &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>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -400,7 +400,7 @@
<span class='doccomment'>/// .help(&quot;Provides a config file to myprog&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Arg</span> {
<span class='doccomment'>/// The unique name of the argument, required</span>
<span class='doccomment'>/// The unique name of the argument, required</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='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>
@ -427,295 +427,295 @@
<span class='doccomment'>/// I.e. `-v -v -v` or `-vvv`</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='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;static</span> <span class='ident'>str</span><span class='op'>&gt;&gt;</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;static</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='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;static</span> <span class='ident'>str</span><span class='op'>&gt;&gt;</span>
}
<span class='kw'>impl</span> <span class='ident'>Arg</span> {
<span class='doccomment'>/// Creates a new instace of `Arg` using a unique string name. </span>
<span class='doccomment'>/// The name will be used by the library consumer to get information about</span>
<span class='doccomment'>/// whether or not the argument was used at runtime. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** in the case of arguments that take values (i.e. `takes_value(true)`)</span>
<span class='doccomment'>/// and positional arguments (i.e. those without a `-` or `--`) the name will also </span>
<span class='doccomment'>/// be displayed when the user prints the usage/help information of the program.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// # .short(&quot;c&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>n</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='ident'>Arg</span> {
<span class='ident'>name</span>: <span class='ident'>n</span>,
<span class='ident'>short</span>: <span class='prelude-val'>None</span>,
<span class='ident'>long</span>: <span class='prelude-val'>None</span>,
<span class='ident'>help</span>: <span class='prelude-val'>None</span>,
<span class='ident'>required</span>: <span class='boolval'>false</span>,
<span class='ident'>takes_value</span>: <span class='boolval'>false</span>,
<span class='ident'>multiple</span>: <span class='boolval'>false</span>,
<span class='ident'>index</span>: <span class='prelude-val'>None</span>,
<span class='ident'>blacklist</span>: <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]),
<span class='ident'>requires</span>: <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]),
}
}
<span class='doccomment'>/// Creates a new instace of `Arg` using a unique string name. </span>
<span class='doccomment'>/// The name will be used by the library consumer to get information about</span>
<span class='doccomment'>/// whether or not the argument was used at runtime. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** in the case of arguments that take values (i.e. `takes_value(true)`)</span>
<span class='doccomment'>/// and positional arguments (i.e. those without a `-` or `--`) the name will also </span>
<span class='doccomment'>/// be displayed when the user prints the usage/help information of the program.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// # .short(&quot;c&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>n</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='ident'>Arg</span> {
<span class='ident'>name</span>: <span class='ident'>n</span>,
<span class='ident'>short</span>: <span class='prelude-val'>None</span>,
<span class='ident'>long</span>: <span class='prelude-val'>None</span>,
<span class='ident'>help</span>: <span class='prelude-val'>None</span>,
<span class='ident'>required</span>: <span class='boolval'>false</span>,
<span class='ident'>takes_value</span>: <span class='boolval'>false</span>,
<span class='ident'>multiple</span>: <span class='boolval'>false</span>,
<span class='ident'>index</span>: <span class='prelude-val'>None</span>,
<span class='ident'>blacklist</span>: <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]),
<span class='ident'>requires</span>: <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]),
}
}
<span class='doccomment'>/// Sets the short version of the argument without the preceding `-`.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// By default `clap` automatically assigns `v` and `h` to display version and help information </span>
<span class='doccomment'>/// respectivly. You may use `v` or `h` for your own purposes, in which case `clap` simply</span>
<span class='doccomment'>/// will not asign those to the displaying of version or help.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Any leading `-` characters will be stripped, and only the first</span>
<span class='doccomment'>/// non `-` chacter will be used as the `short` version, i.e. for when the user</span>
<span class='doccomment'>/// mistakenly sets the short to `-o` or the like.</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .short(&quot;c&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>short</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>short</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>)
.<span class='ident'>char_at</span>(<span class='number'>0</span>));
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets the short version of the argument without the preceding `-`.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// By default `clap` automatically assigns `v` and `h` to display version and help information </span>
<span class='doccomment'>/// respectivly. You may use `v` or `h` for your own purposes, in which case `clap` simply</span>
<span class='doccomment'>/// will not asign those to the displaying of version or help.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Any leading `-` characters will be stripped, and only the first</span>
<span class='doccomment'>/// non `-` chacter will be used as the `short` version, i.e. for when the user</span>
<span class='doccomment'>/// mistakenly sets the short to `-o` or the like.</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .short(&quot;c&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>short</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>short</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>)
.<span class='ident'>char_at</span>(<span class='number'>0</span>));
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets the long version of the argument without the preceding `--`.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// By default `clap` automatically assigns `version` and `help` to display version and help information </span>
<span class='doccomment'>/// respectivly. You may use `version` or `help` for your own purposes, in which case `clap` simply</span>
<span class='doccomment'>/// will not asign those to the displaying of version or help automatically, and you will have to do</span>
<span class='doccomment'>/// so manually.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Any leading `-` characters will be stripped i.e. for </span>
<span class='doccomment'>/// when the user mistakenly sets the short to `--out` or the like.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .long(&quot;config&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>long</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>l</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>long</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>l</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>));
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets the long version of the argument without the preceding `--`.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// By default `clap` automatically assigns `version` and `help` to display version and help information </span>
<span class='doccomment'>/// respectivly. You may use `version` or `help` for your own purposes, in which case `clap` simply</span>
<span class='doccomment'>/// will not asign those to the displaying of version or help automatically, and you will have to do</span>
<span class='doccomment'>/// so manually.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Any leading `-` characters will be stripped i.e. for </span>
<span class='doccomment'>/// when the user mistakenly sets the short to `--out` or the like.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .long(&quot;config&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>long</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>l</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>long</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>l</span>.<span class='ident'>trim_left_matches</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>&#39;-&#39;</span>));
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets the help text of the argument that will be displayed to the user</span>
<span class='doccomment'>/// when they print the usage/help information. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .help(&quot;The config file used by the myprog&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>help</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>h</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>help</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>h</span>);
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets the help text of the argument that will be displayed to the user</span>
<span class='doccomment'>/// when they print the usage/help information. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .help(&quot;The config file used by the myprog&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>help</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>h</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>help</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>h</span>);
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets whether or not the argument is required by default. Required by</span>
<span class='doccomment'>/// default means it is required, when no other mutually exlusive rules have</span>
<span class='doccomment'>/// been evaluated. Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>/// by default.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Flags (i.e. not positional, or arguments that take values)</span>
<span class='doccomment'>/// cannot be required by default.</span>
<span class='doccomment'>/// when they print the usage/help information. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .required(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>required</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>r</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>required</span> <span class='op'>=</span> <span class='ident'>r</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets whether or not the argument is required by default. Required by</span>
<span class='doccomment'>/// default means it is required, when no other mutually exlusive rules have</span>
<span class='doccomment'>/// been evaluated. Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>/// by default.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Flags (i.e. not positional, or arguments that take values)</span>
<span class='doccomment'>/// cannot be required by default.</span>
<span class='doccomment'>/// when they print the usage/help information. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .required(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>required</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>r</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='self'>self</span>.<span class='ident'>required</span> <span class='op'>=</span> <span class='ident'>r</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets a mutually exclusive argument by name. I.e. when using this argument, </span>
<span class='doccomment'>/// the following argument can&#39;t be present.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>/// by default. Mutually exclusive rules only need to be set for one of the two</span>
<span class='doccomment'>/// arguments, they do not need to be set for each.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .mutually_excludes(&quot;debug&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>blacklist</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>name</span>);
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>blacklist</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]);
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets a mutually exclusive argument by name. I.e. when using this argument, </span>
<span class='doccomment'>/// the following argument can&#39;t be present.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>/// by default. Mutually exclusive rules only need to be set for one of the two</span>
<span class='doccomment'>/// arguments, they do not need to be set for each.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .mutually_excludes(&quot;debug&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>blacklist</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>name</span>);
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>blacklist</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]);
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets a mutually exclusive arguments by names. I.e. when using this argument, </span>
<span class='doccomment'>/// the following argument can&#39;t be present.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>/// by default. Mutually exclusive rules only need to be set for one of the two</span>
<span class='doccomment'>/// arguments, they do not need to be set for each.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .mutually_excludes_all(</span>
<span class='doccomment'>/// vec![&quot;debug&quot;, &quot;input&quot;])</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes_all</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>blacklist</span> {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>names</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>n</span>);
}
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>blacklist</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]);
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets a mutually exclusive arguments by names. I.e. when using this argument, </span>
<span class='doccomment'>/// the following argument can&#39;t be present.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>/// by default. Mutually exclusive rules only need to be set for one of the two</span>
<span class='doccomment'>/// arguments, they do not need to be set for each.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .mutually_excludes_all(</span>
<span class='doccomment'>/// vec![&quot;debug&quot;, &quot;input&quot;])</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes_all</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>blacklist</span> {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>names</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>n</span>);
}
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>blacklist</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]);
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets an argument by name that is required when this one is presnet I.e. when</span>
<span class='doccomment'>/// using this argument, the following argument *must* be present.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .requires(&quot;debug&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>requires</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>name</span>);
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>requires</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]);
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets an argument by name that is required when this one is presnet I.e. when</span>
<span class='doccomment'>/// using this argument, the following argument *must* be present.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .requires(&quot;debug&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>requires</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>name</span>);
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>requires</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]);
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets arguments by names that are required when this one is presnet I.e. when</span>
<span class='doccomment'>/// using this argument, the following arguments *must* be present.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>/// by default. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .requires_all(</span>
<span class='doccomment'>/// vec![&quot;debug&quot;, &quot;input&quot;])</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires_all</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>requires</span> {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>names</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>n</span>);
}
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>requires</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]);
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets arguments by names that are required when this one is presnet I.e. when</span>
<span class='doccomment'>/// using this argument, the following arguments *must* be present.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
<span class='doccomment'>/// by default. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let myprog = App::new(&quot;myprog&quot;).arg(Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .requires_all(</span>
<span class='doccomment'>/// vec![&quot;debug&quot;, &quot;input&quot;])</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires_all</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span><span class='op'>&gt;</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>vec</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>requires</span> {
<span class='kw'>for</span> <span class='ident'>n</span> <span class='kw'>in</span> <span class='ident'>names</span> {
<span class='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>n</span>);
}
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>requires</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]);
}
<span class='self'>self</span>
}
<span class='doccomment'>/// Specifies that the argument takes an additional value at run time.</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// **NOTE:** When setting this to `true` the `name` of the argument</span>
<span class='doccomment'>/// will be used when printing the help/usage information to the user. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .takes_value(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>takes_value</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>tv</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>==</span> <span class='prelude-val'>None</span>);
<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>=</span> <span class='ident'>tv</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Specifies that the argument takes an additional value at run time.</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// **NOTE:** When setting this to `true` the `name` of the argument</span>
<span class='doccomment'>/// will be used when printing the help/usage information to the user. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .takes_value(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>takes_value</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>tv</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>==</span> <span class='prelude-val'>None</span>);
<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>=</span> <span class='ident'>tv</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Specifies the index of a positional argument starting at 1.</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// **NOTE:** When setting this, any `short` or `long` values you set</span>
<span class='doccomment'>/// are ignored as positional arguments cannot have a `short` or `long`.</span>
<span class='doccomment'>/// Also, the name will be used when printing the help/usage information </span>
<span class='doccomment'>/// to the user. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .index(1)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>index</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>idx</span>: <span class='ident'>u8</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>==</span> <span class='boolval'>false</span>);
<span class='kw'>if</span> <span class='ident'>idx</span> <span class='op'>&lt;</span> <span class='number'>1</span> { <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument index must start at 1&quot;</span>); }
<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>idx</span>);
<span class='self'>self</span>
}
<span class='doccomment'>/// Specifies the index of a positional argument starting at 1.</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// **NOTE:** When setting this, any `short` or `long` values you set</span>
<span class='doccomment'>/// are ignored as positional arguments cannot have a `short` or `long`.</span>
<span class='doccomment'>/// Also, the name will be used when printing the help/usage information </span>
<span class='doccomment'>/// to the user. </span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .index(1)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>index</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>idx</span>: <span class='ident'>u8</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>==</span> <span class='boolval'>false</span>);
<span class='kw'>if</span> <span class='ident'>idx</span> <span class='op'>&lt;</span> <span class='number'>1</span> { <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Argument index must start at 1&quot;</span>); }
<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>idx</span>);
<span class='self'>self</span>
}
<span class='doccomment'>/// Specifies if the flag may appear more than once such as for multiple debugging</span>
<span class='doccomment'>/// levels (as an example). `-ddd` for three levels of debugging, or `-d -d -d`. </span>
<span class='doccomment'>/// When this is set to `true` you recieve the number of occurances the user supplied</span>
<span class='doccomment'>/// of a particular flag at runtime.</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// **NOTE:** When setting this, any `takes_value` or `index` values you set</span>
<span class='doccomment'>/// are ignored as flags cannot have a values or an `index`.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;debug&quot;)</span>
<span class='doccomment'>/// .multiple(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>multiple</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>multi</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>==</span> <span class='boolval'>false</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>==</span> <span class='prelude-val'>None</span>);
<span class='self'>self</span>.<span class='ident'>multiple</span> <span class='op'>=</span> <span class='ident'>multi</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Specifies if the flag may appear more than once such as for multiple debugging</span>
<span class='doccomment'>/// levels (as an example). `-ddd` for three levels of debugging, or `-d -d -d`. </span>
<span class='doccomment'>/// When this is set to `true` you recieve the number of occurances the user supplied</span>
<span class='doccomment'>/// of a particular flag at runtime.</span>
<span class='doccomment'>/// </span>
<span class='doccomment'>/// **NOTE:** When setting this, any `takes_value` or `index` values you set</span>
<span class='doccomment'>/// are ignored as flags cannot have a values or an `index`.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Example:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg};</span>
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .arg(</span>
<span class='doccomment'>/// # Arg::new(&quot;debug&quot;)</span>
<span class='doccomment'>/// .multiple(true)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>multiple</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>multi</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='ident'>Arg</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>takes_value</span> <span class='op'>==</span> <span class='boolval'>false</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>index</span> <span class='op'>==</span> <span class='prelude-val'>None</span>);
<span class='self'>self</span>.<span class='ident'>multiple</span> <span class='op'>=</span> <span class='ident'>multi</span>;
<span class='self'>self</span>
}
}
</pre>
</section>

View file

@ -325,15 +325,15 @@
<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='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>ArgMatches</span> {
<span class='ident'>ArgMatches</span> {
<span class='ident'>matches_of</span>: <span class='ident'>name</span>,
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>ArgMatches</span> {
<span class='ident'>ArgMatches</span> {
<span class='ident'>matches_of</span>: <span class='ident'>name</span>,
<span class='ident'>flags</span>: <span class='ident'>HashMap</span>::<span class='ident'>new</span>(),
<span class='ident'>opts</span>: <span class='ident'>HashMap</span>::<span class='ident'>new</span>(),
<span class='ident'>positionals</span>: <span class='ident'>HashMap</span>::<span class='ident'>new</span>(),
<span class='ident'>subcommand</span>: <span class='prelude-val'>None</span>
}
}
}
}
<span class='doccomment'>/// Gets the value of a specific option or positional argument (i.e. an argument that takes</span>
<span class='doccomment'>/// an additional value at runtime). If the option wasn&#39;t present at runtime</span>
@ -348,19 +348,19 @@
<span class='doccomment'>/// println!(&quot;Value for output: {}&quot;, o);</span>
<span class='doccomment'>/// }</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>value_of</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>String</span><span class='op'>&gt;</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>value_of</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>String</span><span class='op'>&gt;</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'>name</span>) {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>v</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>value</span> {
<span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>v</span>);
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>v</span>) <span class='op'>=</span> <span class='ident'>opt</span>.<span class='ident'>value</span> {
<span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>v</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'>pos</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>positionals</span>.<span class='ident'>get</span>(<span class='ident'>name</span>) {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>v</span>) <span class='op'>=</span> <span class='ident'>pos</span>.<span class='ident'>value</span> {
<span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>v</span>);
}
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>v</span>) <span class='op'>=</span> <span class='ident'>pos</span>.<span class='ident'>value</span> {
<span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>v</span>);
}
}
<span class='prelude-val'>None</span>
}
}
<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>
@ -375,7 +375,7 @@
<span class='doccomment'>/// println!(&quot;The output argument was used!&quot;);</span>
<span class='doccomment'>/// }</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_present</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>bool</span> {
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_present</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>bool</span> {
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>((<span class='ident'>sc_name</span>, _ )) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>subcommand</span> {
<span class='kw'>if</span> <span class='ident'>sc_name</span> <span class='op'>==</span> <span class='ident'>name</span> { <span class='kw'>return</span> <span class='boolval'>true</span>; }
}
@ -385,7 +385,7 @@
<span class='kw'>return</span> <span class='boolval'>true</span>;
}
<span class='boolval'>false</span>
}
}
<span class='doccomment'>/// Checks the number of occurrences of a flag at runtime.</span>
<span class='doccomment'>///</span>

View file

@ -220,50 +220,50 @@
<span class='doccomment'>//! // ...</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! let matches = App::new(&quot;MyApp&quot;)</span>
<span class='doccomment'>//! .version(&quot;1.0&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'>//! .arg(Arg::new(&quot;config&quot;)</span>
<span class='doccomment'>//! .short(&quot;c&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'>//! .takes_value(true))</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'>//! .index(1))</span>
<span class='doccomment'>//! .arg(Arg::new(&quot;debug&quot;)</span>
<span class='doccomment'>//! .short(&quot;d&quot;)</span>
<span class='doccomment'>//! .multiple(true)</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'>//! .about(&quot;Has test sub functionality&quot;)</span>
<span class='doccomment'>//! .arg(Arg::new(&quot;verbose&quot;)</span>
<span class='doccomment'>//! .short(&quot;v&quot;)</span>
<span class='doccomment'>//! .help(&quot;Display verbose information&quot;)))</span>
<span class='doccomment'>//! .get_matches();</span>
<span class='doccomment'>//! .version(&quot;1.0&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'>//! .arg(Arg::new(&quot;config&quot;)</span>
<span class='doccomment'>//! .short(&quot;c&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'>//! .takes_value(true))</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'>//! .index(1))</span>
<span class='doccomment'>//! .arg(Arg::new(&quot;debug&quot;)</span>
<span class='doccomment'>//! .short(&quot;d&quot;)</span>
<span class='doccomment'>//! .multiple(true)</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'>//! .about(&quot;Has test sub functionality&quot;)</span>
<span class='doccomment'>//! .arg(Arg::new(&quot;verbose&quot;)</span>
<span class='doccomment'>//! .short(&quot;v&quot;)</span>
<span class='doccomment'>//! .help(&quot;Display verbose information&quot;)))</span>
<span class='doccomment'>//! .get_matches();</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! if let Some(o) = matches.value_of(&quot;output&quot;) {</span>
<span class='doccomment'>//! println!(&quot;Value for output: {}&quot;, o);</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//! if let Some(o) = matches.value_of(&quot;output&quot;) {</span>
<span class='doccomment'>//! println!(&quot;Value for output: {}&quot;, o);</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! if let Some(c) = matches.value_of(&quot;config&quot;) {</span>
<span class='doccomment'>//! println!(&quot;Value for config: {}&quot;, c);</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//! if let Some(c) = matches.value_of(&quot;config&quot;) {</span>
<span class='doccomment'>//! println!(&quot;Value for config: {}&quot;, c);</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! match matches.occurrences_of(&quot;debug&quot;) {</span>
<span class='doccomment'>//! 0 =&gt; println!(&quot;Debug mode is off&quot;),</span>
<span class='doccomment'>//! 1 =&gt; println!(&quot;Debug mode is kind of 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'>//! 0 =&gt; println!(&quot;Debug mode is off&quot;),</span>
<span class='doccomment'>//! 1 =&gt; println!(&quot;Debug mode is kind of 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'>//! }</span>
<span class='doccomment'>//! </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'>//! println!(&quot;Printing verbose test info...&quot;);</span>
<span class='doccomment'>//! } else {</span>
<span class='doccomment'>//! println!(&quot;Not printing regular test info...&quot;);</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//! }</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'>//! } else {</span>
<span class='doccomment'>//! println!(&quot;Not printing regular test info...&quot;);</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! // more porgram logic goes here...</span>
<span class='doccomment'>//! ```</span>
@ -277,22 +277,22 @@
<span class='doccomment'>//! Does awesome things</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! USAGE:</span>
<span class='doccomment'>//! MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]</span>
<span class='doccomment'>//! MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! FLAGS:</span>
<span class='doccomment'>//! -d Turn debugging information on</span>
<span class='doccomment'>//! -h,--help Prints this message</span>
<span class='doccomment'>//! -v,--version Prints version information</span>
<span class='doccomment'>//! -d Turn debugging information on</span>
<span class='doccomment'>//! -h,--help Prints this message</span>
<span class='doccomment'>//! -v,--version Prints version information</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! OPTIONS:</span>
<span class='doccomment'>//! -c,--config &lt;config&gt; Sets a custom config file</span>
<span class='doccomment'>//! -c,--config &lt;config&gt; Sets a custom config file</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! POSITIONAL ARGUMENTS:</span>
<span class='doccomment'>//! output Sets an optional output file</span>
<span class='doccomment'>//! output Sets an optional output file</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! SUBCOMMANDS:</span>
<span class='doccomment'>//! help Prints this message</span>
<span class='doccomment'>//! test Has test sub-functionality</span>
<span class='doccomment'>//! help Prints this message</span>
<span class='doccomment'>//! test Has test sub-functionality</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>;
@ -310,46 +310,46 @@
<span class='kw'>mod</span> <span class='ident'>tests</span> {
<span class='kw'>use</span> <span class='ident'>super</span>::<span class='op'>*</span>;
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_panic</span>]</span>
<span class='kw'>fn</span> <span class='ident'>unique_arg_names</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;b&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_panic</span>]</span>
<span class='kw'>fn</span> <span class='ident'>unique_arg_shorts</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg1&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg2&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_panic</span>]</span>
<span class='kw'>fn</span> <span class='ident'>unique_arg_longs</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg1&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg2&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_app</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>about</span>(<span class='string'>&quot;about&quot;</span>).<span class='ident'>author</span>(<span class='string'>&quot;author&quot;</span>).<span class='ident'>version</span>(<span class='string'>&quot;1.0&quot;</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_flag</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>multiple</span>(<span class='boolval'>true</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_pos</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>index</span>(<span class='number'>1</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_opt</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;s&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>takes_value</span>(<span class='boolval'>true</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_panic</span>]</span>
<span class='kw'>fn</span> <span class='ident'>unique_arg_names</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;b&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_panic</span>]</span>
<span class='kw'>fn</span> <span class='ident'>unique_arg_shorts</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg1&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg2&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='attribute'>#[<span class='ident'>should_panic</span>]</span>
<span class='kw'>fn</span> <span class='ident'>unique_arg_longs</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg1&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>),
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;arg2&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>)
]);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_app</span>(){
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>about</span>(<span class='string'>&quot;about&quot;</span>).<span class='ident'>author</span>(<span class='string'>&quot;author&quot;</span>).<span class='ident'>version</span>(<span class='string'>&quot;1.0&quot;</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_flag</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;a&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;long&quot;</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>multiple</span>(<span class='boolval'>true</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_pos</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>index</span>(<span class='number'>1</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>create_arg_opt</span>(){
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>short</span>(<span class='string'>&quot;s&quot;</span>).<span class='ident'>long</span>(<span class='string'>&quot;some&quot;</span>).<span class='ident'>takes_value</span>(<span class='boolval'>true</span>).<span class='ident'>help</span>(<span class='string'>&quot;help with some arg&quot;</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
}
}
</pre>
</section>

View file

@ -101,31 +101,31 @@
<span class='doccomment'>/// # let matches = App::new(&quot;myprog&quot;)</span>
<span class='doccomment'>/// # .subcommand(</span>
<span class='doccomment'>/// SubCommand::new(&quot;conifg&quot;)</span>
<span class='doccomment'>/// .about(&quot;Used for configuration&quot;)</span>
<span class='doccomment'>/// .arg(Arg::new(&quot;config_file&quot;)</span>
<span class='doccomment'>/// .help(&quot;The configuration file to use&quot;)</span>
<span class='doccomment'>/// .index(1))</span>
<span class='doccomment'>/// .about(&quot;Used for configuration&quot;)</span>
<span class='doccomment'>/// .arg(Arg::new(&quot;config_file&quot;)</span>
<span class='doccomment'>/// .help(&quot;The configuration file to use&quot;)</span>
<span class='doccomment'>/// .index(1))</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SubCommand</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='kw'>pub</span> <span class='ident'>matches</span>: <span class='ident'>ArgMatches</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='kw'>pub</span> <span class='ident'>matches</span>: <span class='ident'>ArgMatches</span>
}
<span class='kw'>impl</span> <span class='ident'>SubCommand</span> {
<span class='doccomment'>/// Creates a new instance of a subcommand requiring a name. Will be displayed</span>
<span class='doccomment'>/// to the user when they print version or help and usage information.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</span>
<span class='doccomment'>/// # let prog = App::new(&quot;myprog&quot;).subcommand(</span>
<span class='doccomment'>/// SubCommand::new(&quot;config&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>App</span> {
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='ident'>name</span>)
}
<span class='doccomment'>/// Creates a new instance of a subcommand requiring a name. Will be displayed</span>
<span class='doccomment'>/// to the user when they print version or help and usage information.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Example</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```no_run</span>
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</span>
<span class='doccomment'>/// # let prog = App::new(&quot;myprog&quot;).subcommand(</span>
<span class='doccomment'>/// SubCommand::new(&quot;config&quot;)</span>
<span class='doccomment'>/// # ).get_matches();</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;static</span> <span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>App</span> {
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='ident'>name</span>)
}
}
</pre>
</section>