chore(docs): rebuild documentation with new features

This commit is contained in:
Kevin K 2015-04-09 18:46:10 -04:00
parent 53af3fe86b
commit 73ca72261e
10 changed files with 321 additions and 137 deletions

View file

@ -43,16 +43,24 @@
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Crate <a class='mod' href=''>clap</a><wbr></span><span class='out-of-band'><a href='stability.html'>[stability]</a> <span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-0' href='../src/clap/lib.rs.html#1-323'>[src]</a></span></h1>
</span><a id='src-0' href='../src/clap/lib.rs.html#1-339'>[src]</a></span></h1>
<div class='docblock'>
<h1 id="clap" class='section-header'><a
href="#clap">clap</a></h1>
<p><img src="https://travis-ci.org/kbknapp/clap-rs.svg?branch=master" alt="Travis-CI"></p>
<p><img src="https://travis-ci.org/kbknapp/clap-rs.svg?branch=master" alt="Travis-CI"> <a href="https://gitter.im/kbknapp/clap-rs?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/kbknapp/clap-rs"></a></p>
<p>Command Line Argument Parser written in Rust</p>
<p>It is a simple to use and efficient library for parsing command line arguments and subcommands when writing console, or terminal applications.</p>
<h2 id="video-tutorials" class='section-header'><a
href="#video-tutorials">Video Tutorials</a></h2>
<p>I&#39;ve been working on a few short video tutorials about using <code>clap</code>. They&#39;re located on <a href="https://www.youtube.com/playlist?list=PLza5oFLQGTl0Bc_EU_pBNcX-rhVqDTRxv">youtube</a>. </p>
<p><em>Note</em>: Apologies for the resolution of the first video, it will be updated to a better resolution soon. The other videos have a proper resolution.</p>
<h2 id="about" class='section-header'><a
href="#about">About</a></h2>
<p>You can use <code>clap</code> to lay out a list of possible valid command line arguments and subcommands, then let <code>clap</code> parse <em>and validate</em> the string given by the user at runtime. This means you focus on your applications functionality, not parsing and validating arguments.</p>
<p>What is different about <code>clap</code> from other options available is the very simple almost &#39;Pythonic&#39; style in which you define the valid available arguments for your program, while still giving advanced features. <code>clap</code> allows you express complex relationships between arguments in a very simple manner. This means you don&#39;t have to spend tons time learning an entirely new library&#39;s structures and use. The basics of <code>clap</code> can be learned almost intuitively.</p>
@ -69,32 +77,32 @@
<li><strong>Auto-generated Help, Version, and Usage information</strong>
<ul>
<li>Can be fully, or partially overridden if you wish to roll your own help, version, or usage</li>
<li>Can optionally be fully, or partially overridden if you want a custom help, version, or usage</li>
</ul></li>
<li><strong>Flags / Switches</strong> (i.e. bool fields)
<ul>
<li>Both short and long versions supported (i.e. <code>-f</code> and <code>--flag</code> respectively)</li>
<li>Supports combining short versions (i.e. <code>-fBgoZ</code> is the same as <code>-f -B -g -o -Z</code>)</li>
<li>Also supports multiple occurrences (i.e. <code>myprog -vvv</code> or <code>myprog -v -v -v</code>)</li>
<li>Optionally supports multiple occurrences (i.e. <code>myprog -vvv</code> or <code>myprog -v -v -v</code>)</li>
</ul></li>
<li><strong>Positional Arguments</strong> (i.e. those which are based off an index)
<li><strong>Positional Arguments</strong> (i.e. those which are based off an index from the program name)
<ul>
<li>Also supports multiple values (i.e. <code>myprog &lt;file&gt;...</code></li>
<li>Supports Specific Value Sets (See below)</li>
<li>Optionally supports multiple values (i.e. <code>myprog &lt;file&gt;...</code> such as <code>myprog file1.txt file2.txt</code> being two values for the same &quot;file&quot; argument)</li>
<li>Optionally supports Specific Value Sets (See below)</li>
</ul></li>
<li><strong>Option Arguments</strong> (i.e. those that take values as options)
<ul>
<li>Both short and long versions supported (i.e. <code>-o value</code> and <code>--option value</code> or <code>--option=value</code> respectively)</li>
<li>Also supports multiple values (i.e. <code>myprog --option &lt;value&gt; --option &lt;othervalue&gt;</code>)</li>
<li>Supports Specific Value Sets (See below)</li>
<li>Optionally supports multiple values (i.e. <code>myprog --option &lt;value&gt; --option &lt;other_value&gt;</code>)</li>
<li>Optionally supports Specific Value Sets (See below)</li>
</ul></li>
<li><strong>Sub-Commands</strong> (i.e. <code>git add &lt;file&gt;</code> where <code>add</code> is a sub-command of <code>git</code>)
<ul>
<li>Support their own sub-arguments, and sub-commands</li>
<li>Support their own sub-arguments, and sub-commands independant of the parent</li>
<li>Get their own auto-generated Help, Version, and Usage independant of parent</li>
</ul></li>
<li><strong>Requirement Rules</strong>: Arguments can optionally define the following types of requirement rules
@ -112,19 +120,19 @@
</ul></li>
<li><strong>Specific Value Sets</strong>: Positional or Option Arguments can optionally define a specific set of allowed values (i.e. imagine a <code>--mode</code> option which may <em>only</em> have one of two values <code>fast</code> or <code>slow</code> such as <code>--mode fast</code> or <code>--mode slow</code>)</li>
<li><strong>Default Values</strong>: Although not specifically provided by <code>clap</code> you can achieve this exact functionality from Rust&#39;s <code>Option&lt;&amp;str&gt;.unwrap_or(&quot;some default&quot;)</code> method</li>
<li><strong>Auto Version from Cargo.toml</strong>: <code>clap</code> is fully compatible with Rust&#39;s <code>env!()</code> macro for achieving this functionality. See <code>examples/09_AutoVersion.rs</code> for how to do this (Thanks to <a href="https://github.com/jhelwig">jhelwig</a> for pointing this out)</li>
<li><strong>Get Version from Cargo.toml</strong>: <code>clap</code> is fully compatible with Rust&#39;s <code>env!()</code> macro for automatically getting the version from your Cargo.toml. See <code>examples/09_AutoVersion.rs</code> for how to do this (Thanks to <a href="https://github.com/jhelwig">jhelwig</a> for pointing this out)</li>
</ul>
<h2 id="quick-example" class='section-header'><a
href="#quick-example">Quick Example</a></h2>
<p>The following shows a quick example of some of the basic functionality of <code>clap</code>. For more advanced usage, such as requirements, exclusions, multiple values and occurrences see the <a href="http://kbknapp.github.io/clap-rs/docs/clap/index.html">documentation</a> or <code>examples/</code> directory of this repository.</p>
<p>The following shows a quick example of some of the basic functionality of <code>clap</code>. For more advanced usage, such as requirements, exclusions, multiple values and occurrences see the <a href="https://www.youtube.com/playlist?list=PLza5oFLQGTl0Bc_EU_pBNcX-rhVqDTRxv">video tutorials</a>, <a href="http://kbknapp.github.io/clap-rs/docs/clap/index.html">documentation</a>, or <code>examples/</code> directory of this repository.</p>
<pre id='rust-example-rendered' class='rust '>
<span class='comment'>// (Full example with comments in examples/01_QuickExample.rs)</span>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>clap</span>;
<span class='kw'>use</span> <span class='ident'>clap</span>::{<span class='ident'>Arg</span>, <span class='ident'>App</span>, <span class='ident'>SubCommand</span>};
<span class='kw'>fn</span> <span class='ident'>main</span>() {
<span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>&quot;MyApp&quot;</span>)
<span class='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>)
@ -133,8 +141,9 @@
.<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'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>&quot;INPUT&quot;</span>)
.<span class='ident'>help</span>(<span class='string'>&quot;Sets the input file to use&quot;</span>)
.<span class='ident'>required</span>(<span class='boolval'>true</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>)
@ -142,19 +151,23 @@
.<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;controls testing features&quot;</span>)
.<span class='ident'>version</span>(<span class='string'>&quot;1.3&quot;</span>)
.<span class='ident'>author</span>(<span class='string'>&quot;Someone E. &lt;someone_else@other.com&gt;&quot;</span>)
.<span class='ident'>arg</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;print test information verbosely&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'>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='comment'>// Calling .unwrap() is safe here because &quot;INPUT&quot; is required (if &quot;INPUT&quot; wasn&#39;t</span>
<span class='comment'>// required we could have used an &#39;if let&#39; to conditionally get the value)</span>
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Using input file: {}&quot;</span>, <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;INPUT&quot;</span>).<span class='ident'>unwrap</span>());
<span class='comment'>// Gets a value for config if supplied by user, or defaults to &quot;default.conf&quot;</span>
<span class='kw'>let</span> <span class='ident'>config</span> <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>&quot;CONFIG&quot;</span>).<span class='ident'>unwrap_or</span>(<span class='string'>&quot;default.conf&quot;</span>);
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Value for config: {}&quot;</span>, <span class='ident'>config</span>);
<span class='comment'>// Vary the output based on how many times the user used the &quot;debug&quot; flag</span>
<span class='comment'>// (i.e. &#39;myapp -d -d -d&#39; or &#39;myapp -ddd&#39; vs &#39;myapp -d&#39; </span>
<span class='kw'>match</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>&quot;debug&quot;</span>) {
<span class='number'>0</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is off&quot;</span>),
<span class='number'>1</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Debug mode is kind of on&quot;</span>),
@ -162,7 +175,7 @@
<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='ident'>matches</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>subcommand_matches</span>(<span class='string'>&quot;test&quot;</span>) {
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>is_present</span>(<span class='string'>&quot;verbose&quot;</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;Printing verbosely...&quot;</span>);
} <span class='kw'>else</span> {
@ -174,32 +187,34 @@
}
</pre>
<p>If you were to compile the above program and run it with the flag <code>--help</code> or <code>-h</code> (or <code>help</code> subcommand, since we defined <code>test</code> as a subcommand) the following output woud be presented</p>
<p>If you were to compile the above program and run it with the flag <code>--help</code> or <code>-h</code> (or <code>help</code> subcommand, since we defined <code>test</code> as a subcommand) the following would be output</p>
<pre><code class="language-sh">$ myprog --help
MyApp 1.0
<pre><code class="language-sh">$ myapp --help
myapp 1.0
Kevin K. &lt;kbknapp@gmail.com&gt;
Does awesome things
USAGE:
MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]
MyApp [FLAGS] [OPTIONS] &lt;INPUT&gt; [SUBCOMMANDS]
FLAGS:
-d Turn debugging information on
-h,--help Prints this message
-v,--version Prints version information
-h, --help Prints this message
-v, --version Prints version information
OPTIONS:
-c,--config=CONFIG Sets a custom config file
-c, --config=CONFIG Sets a custom config file
POSITIONAL ARGUMENTS:
output Sets an optional output file
INPUT The input file to use
SUBCOMMANDS:
help Prints this message
test Controls testing features
help Prints this message
test Controls testing features
</code></pre>
<p><em>NOTE:</em> You could also run <code>myapp test --help</code> to see similar output and options for the <code>test</code> subcommand.</p>
<h2 id="installation" class='section-header'><a
href="#installation">Installation</a></h2>
<p>Add <code>clap</code> as a dependecy in your <code>Cargo.toml</code> file to use from crates.io:</p>
@ -216,54 +231,52 @@ SUBCOMMANDS:
<p>Add <code>extern crate clap;</code> to your crate root.</p>
<p>Define a list of valid arguments for your program (see the documentation or examples/ directory)</p>
<p>Define a list of valid arguments for your program (see the <a href="https://kbknapp.github.io/clap-rs/index.html">documentation</a> or <code>examples/</code> directory of this repo)</p>
<p>Then run <code>cargo build</code> or <code>cargo update &amp;&amp; cargo build</code> for your project.</p>
<h2 id="more-information" class='section-header'><a
href="#more-information">More Information</a></h2>
<h3 id="more-information" class='section-header'><a
href="#more-information">More Information</a></h3>
<p>You can find complete documentation on the <a href="http://kbknapp.github.io/clap-rs/docs/clap/index.html">github-pages site</a> for this project.</p>
<p>You can also find full usage examples in the <code>examples/</code> directory of this repo.</p>
<p>You can also find usage examples in the <code>examples/</code> directory of this repo.</p>
<h2 id="how-to-build-and-contribute" class='section-header'><a
href="#how-to-build-and-contribute">How to build and contribute</a></h2>
<h2 id="how-to-contribute" class='section-header'><a
href="#how-to-contribute">How to Contribute</a></h2>
<p>Contributions are always welcome! And there is a multitude of ways in which you can help depending on what you like to do, or are good at. Anything from documentation, code cleanup, issue completion, new features, you name it, even filing issues is contributing and greatly appreciated!</p>
<ol>
<li>Fork the project</li>
<li>Clone your fork (<code>git clone https://github.com/$USER/clap-rs &amp;&amp; cd clap-rs</code>)</li>
<li>Create new branch (<code>git checkout -b your-branch</code>)</li>
<li>Make your changes, and commit (<code>git commit -am &quot;your message&quot;</code>)</li>
<li>Clone your fork (<code>git clone https://github.com/$YOUR_USERNAME/clap-rs &amp;&amp; cd clap-rs</code>)</li>
<li>Create new branch (<code>git checkout -b new-branch</code>)</li>
<li>Make your changes, and commit (<code>git commit -am &quot;your message&quot;</code>) (I try to use a <a href="https://github.com/ajoslin/conventional-changelog/blob/master/CONVENTIONS.md">conventional</a> changelog format so I can update it using <a href="https://github.com/thoughtram/clog">clog</a>)</li>
<li>If applicable, run the tests (See below)</li>
<li>Push your changes back to your fork (<code>git push origin your-branch</code>)</li>
<li>Create a pull request! (You can create the pull request right away, and we&#39;ll merge when read. This a good way to discuss proposed changes)</li>
<li>Create a pull request! (You can also create the pull request right away, and we&#39;ll merge when ready. This a good way to discuss proposed changes.) </li>
</ol>
<p>Another really great way to help is if you find an interesting, or helpful way in which to use <code>clap</code> you can either add it to the <code>examples/</code> directory, or file an issue and tell me. I&#39;m all about giving credit where credit is due :)</p>
<p>Another really great way to help is if you find an interesting, or helpful way in which to use <code>clap</code>. You can either add it to the <code>examples/</code> directory, or file an issue and tell me. I&#39;m all about giving credit where credit is due :)</p>
<h3 id="running-the-tests" class='section-header'><a
href="#running-the-tests">Running the tests</a></h3>
<p>If contributing, you can run the tests as follows (assuming you&#39;ve already cloned the repo to <code>clap-rs/</code></p>
<p>If contributing, you can run the tests as follows (assuming you&#39;ve cloned the repo to <code>clap-rs/</code></p>
<pre id='rust-example-rendered' class='rust '>
<span class='ident'>cd</span> <span class='ident'>clap</span><span class='op'>-</span><span class='ident'>rs</span>
<span class='ident'>cargo</span> <span class='ident'>test</span>
<span class='ident'>cd</span> <span class='ident'>claptests</span>
<span class='ident'>make</span> <span class='ident'>test</span>
<span class='ident'>cd</span> <span class='ident'>clap</span><span class='op'>-</span><span class='ident'>rs</span> <span class='op'>&amp;&amp;</span> <span class='ident'>cargo</span> <span class='ident'>test</span>
<span class='ident'>cd</span> <span class='ident'>clap</span><span class='op'>-</span><span class='ident'>tests</span> <span class='op'>&amp;&amp;</span> <span class='ident'>make</span> <span class='ident'>test</span>
</pre>
<h3 id="building-the-documentation" class='section-header'><a
href="#building-the-documentation">Building the documentation</a></h3>
<p>If the changes require re-building the documentation, run this instead of <code>cargo doc</code> to generate the proper module docstring:</p>
<p>If your changes require re-building the documentation, run this instead of <code>cargo doc</code> to generate the proper module docstring:</p>
<pre id='rust-example-rendered' class='rust '>
<span class='ident'>make</span> <span class='ident'>doc</span>
<span class='ident'>cd</span> <span class='ident'>clap</span><span class='op'>-</span><span class='ident'>rs</span> <span class='op'>&amp;&amp;</span> <span class='ident'>make</span> <span class='ident'>doc</span>
</pre>
<p>Then browse to <code>clap-rs/docs/clap/index.html</code> in your web-browser of choice to check it out. You can then create a PR on the <code>gh-pages</code> branch</p>
<p>Then browse to <code>clap-rs/docs/clap/index.html</code> in your web-browser of choice to check it out.</p>
<h3 id="goals" class='section-header'><a
href="#goals">Goals</a></h3>
<p>There are a few goals of <code>clap</code> that I&#39;d like to maintain. If your proposed changes break, or go against any of these goals we&#39;ll discuss the changes further before merging (but will <em>not</em> be ignored, all contributes are welcome!). These are by no means hard-and-fast rules, as I&#39;m no expert and break them myself from time to time (even if just by mistake or ignorance :P).</p>
<p>There are a few goals of <code>clap</code> that I&#39;d like to maintain throughout contributions. If your proposed changes break, or go against any of these goals we&#39;ll discuss the changes further before merging (but will <em>not</em> be ignored, all contributes are welcome!). These are by no means hard-and-fast rules, as I&#39;m no expert and break them myself from time to time (even if by mistake or ignorance :P).</p>
<ul>
<li>Remain backwards compatible when possible
@ -276,15 +289,19 @@ SUBCOMMANDS:
<ul>
<li>Parsing of arguments shouldn&#39;t slow down usage of the main program</li>
<li>This is also true of generating help and usage information</li>
<li>This is also true of generating help and usage information (although <em>slightly</em> less stringent, as the program is about to exit)</li>
</ul></li>
<li>Try not to be cognizant of memory usage
<li>Try to be cognizant of memory usage
<ul>
<li>Once parsing is complete, the memory footprint of <code>clap</code> should be low since the main program is the star of the show</li>
</ul></li>
<li><code>panic!</code> on <em>developer</em> error, exit gracefully on <em>end-user</em> error</li>
</ul>
<h2 id="license" class='section-header'><a
href="#license">License</a></h2>
<p><code>clap</code> is licensed under the MIT license. Please the LICENSE-MIT file in this repository for more information.</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr>

View file

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

View file

@ -43,7 +43,7 @@
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>App</a><wbr></span><span class='out-of-band'><span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-32' href='../src/clap/app.rs.html#38-65'>[src]</a></span></h1>
</span><a id='src-33' href='../src/clap/app.rs.html#39-66'>[src]</a></span></h1>
<pre class='rust struct'>pub struct App&lt;'a, 'v, 'ab, 'u, 'ar&gt; {
// some fields omitted
}</pre><div class='docblock'><p>Used to create a representation of the program and all possible command line arguments

View file

@ -43,7 +43,7 @@
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>Arg</a><wbr></span><span class='out-of-band'><span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-8241' href='../src/clap/args/arg.rs.html#21-55'>[src]</a></span></h1>
</span><a id='src-8250' href='../src/clap/args/arg.rs.html#21-55'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Arg&lt;'n, 'l, 'h, 'b, 'p, 'r&gt; {
pub name: &amp;'n <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
pub short: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a href='http://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>&gt;,

View file

@ -43,12 +43,13 @@
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>ArgMatches</a><wbr></span><span class='out-of-band'><span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-8822' href='../src/clap/args/argmatches.rs.html#62-68'>[src]</a></span></h1>
</span><a id='src-8831' href='../src/clap/args/argmatches.rs.html#62-69'>[src]</a></span></h1>
<pre class='rust struct'>pub struct ArgMatches&lt;'a&gt; {
pub flags: <a class='struct' href='http://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html' title='std::collections::hash::map::HashMap'>HashMap</a>&lt;&amp;'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, FlagArg&gt;,
pub opts: <a class='struct' href='http://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html' title='std::collections::hash::map::HashMap'>HashMap</a>&lt;&amp;'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, OptArg&gt;,
pub positionals: <a class='struct' href='http://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html' title='std::collections::hash::map::HashMap'>HashMap</a>&lt;&amp;'a <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, PosArg&gt;,
pub subcommand: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='http://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html' title='alloc::boxed::Box'>Box</a>&lt;<a class='struct' href='../clap/struct.SubCommand.html' title='clap::SubCommand'>SubCommand</a>&lt;'a&gt;&gt;&gt;,
pub usage: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='http://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a>&gt;,
}</pre><div class='docblock'><p>Used to get information about the arguments that
where supplied to the program at runtime.</p>
@ -95,7 +96,7 @@ the methods in order to query information.</p>
}
</pre>
</div><h2 class='fields'>Fields</h2>
<table><tr><td id='structfield.flags'><a class='stability Unmarked' title='No stability level'></a><code>flags</code></td><td></td></tr><tr><td id='structfield.opts'><a class='stability Unmarked' title='No stability level'></a><code>opts</code></td><td></td></tr><tr><td id='structfield.positionals'><a class='stability Unmarked' title='No stability level'></a><code>positionals</code></td><td></td></tr><tr><td id='structfield.subcommand'><a class='stability Unmarked' title='No stability level'></a><code>subcommand</code></td><td></td></tr></table><h2 id='methods'>Methods</h2><h3 class='impl'><a class='stability Unmarked' title='No stability level'></a><code>impl&lt;'a&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;</code></h3><div class='impl-items'><h4 id='method.new' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.new' class='fnname'>new</a>() -&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;</code></h4>
<table><tr><td id='structfield.flags'><a class='stability Unmarked' title='No stability level'></a><code>flags</code></td><td></td></tr><tr><td id='structfield.opts'><a class='stability Unmarked' title='No stability level'></a><code>opts</code></td><td></td></tr><tr><td id='structfield.positionals'><a class='stability Unmarked' title='No stability level'></a><code>positionals</code></td><td></td></tr><tr><td id='structfield.subcommand'><a class='stability Unmarked' title='No stability level'></a><code>subcommand</code></td><td></td></tr><tr><td id='structfield.usage'><a class='stability Unmarked' title='No stability level'></a><code>usage</code></td><td></td></tr></table><h2 id='methods'>Methods</h2><h3 class='impl'><a class='stability Unmarked' title='No stability level'></a><code>impl&lt;'a&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;</code></h3><div class='impl-items'><h4 id='method.new' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.new' class='fnname'>new</a>() -&gt; <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;</code></h4>
<div class='docblock'><p>Creates a new instance of <code>ArgMatches</code>. This ins&#39;t called directly, but
through the <code>.get_matches()</code> method of <code>App</code></p>
@ -177,6 +178,24 @@ allow multiple occurrences, it will return <code>1</code> no matter how many tim
_ <span class='op'>=&gt;</span> {}, <span class='comment'>// Either no subcommand or one not tested for...</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>(&amp;self) -&gt; <a href='http://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(&amp;<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;<a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&gt;)</a></code></h4>
<div class='docblock'><p>If a subcommand was found, returns the name and matches associated with it</p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
<span class='kw'>match</span> <span class='ident'>app_matches</span>.<span class='ident'>subcommand</span>() {
(<span class='string'>&quot;test&quot;</span>, <span class='prelude-val'>Some</span>(<span class='ident'>matches</span>)) <span class='op'>=&gt;</span> {}, <span class='comment'>// test was used</span>
(<span class='string'>&quot;config&quot;</span>, <span class='prelude-val'>Some</span>(<span class='ident'>matches</span>)) <span class='op'>=&gt;</span> {}, <span class='comment'>// config was used</span>
_ <span class='op'>=&gt;</span> {}, <span class='comment'>// Either no subcommand or one not tested for...</span>
}
</pre>
</div><h4 id='method.usage' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.usage' class='fnname'>usage</a>(&amp;self) -&gt; <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;&amp;<a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;</code></h4>
<div class='docblock'><p>Returns a slice of the default usage for the <em>top level parent App only</em></p>
<h1 id="example" class='section-header'><a
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>,<span class='ident'>app_matches</span>.<span class='ident'>usage</span>().<span class='ident'>unwrap</span>());
</pre>
</div></div></section>
<section id='search' class="content hidden"></section>

View file

@ -43,7 +43,7 @@
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>SubCommand</a><wbr></span><span class='out-of-band'><span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a>
</span><a id='src-9246' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
</span><a id='src-9325' href='../src/clap/args/subcommand.rs.html#23-26'>[src]</a></span></h1>
<pre class='rust struct'>pub struct SubCommand&lt;'a&gt; {
pub name: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a>,
pub matches: <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a>&lt;'a&gt;,

File diff suppressed because one or more lines are too long

View file

@ -1282,6 +1282,24 @@
<span id="1240">1240</span>
<span id="1241">1241</span>
<span id="1242">1242</span>
<span id="1243">1243</span>
<span id="1244">1244</span>
<span id="1245">1245</span>
<span id="1246">1246</span>
<span id="1247">1247</span>
<span id="1248">1248</span>
<span id="1249">1249</span>
<span id="1250">1250</span>
<span id="1251">1251</span>
<span id="1252">1252</span>
<span id="1253">1253</span>
<span id="1254">1254</span>
<span id="1255">1255</span>
<span id="1256">1256</span>
<span id="1257">1257</span>
<span id="1258">1258</span>
<span id="1259">1259</span>
<span id="1260">1260</span>
</pre><pre class='rust '>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeMap</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeSet</span>;
@ -1291,6 +1309,7 @@
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>vec</span>::<span class='ident'>IntoIter</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::<span class='ident'>ToOwned</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>process</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>::<span class='ident'>Write</span>;
<span class='kw'>use</span> <span class='ident'>args</span>::{ <span class='ident'>ArgMatches</span>, <span class='ident'>Arg</span>, <span class='ident'>SubCommand</span> };
<span class='kw'>use</span> <span class='ident'>args</span>::{<span class='ident'>FlagArg</span>, <span class='ident'>FlagBuilder</span>};
@ -1684,11 +1703,13 @@
<span class='self'>self</span>
}
<span class='kw'>fn</span> <span class='ident'>print_usage</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>more_info</span>: <span class='ident'>bool</span>) {
<span class='kw'>fn</span> <span class='ident'>create_usage</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>String</span> {
<span class='kw'>let</span> <span class='ident'>tab</span> <span class='op'>=</span> <span class='string'>&quot; &quot;</span>;
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;USAGE:&quot;</span>);
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>usage</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>75</span>);
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='string'>&quot;USAGE:\n&quot;</span>);
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='ident'>tab</span>);
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>u</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>usage_str</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}{}&quot;</span>,<span class='ident'>tab</span>,<span class='ident'>u</span>);
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='ident'>u</span>);
} <span class='kw'>else</span> {
<span class='kw'>let</span> <span class='ident'>flags</span> <span class='op'>=</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>is_empty</span>();
<span class='kw'>let</span> <span class='ident'>pos</span> <span class='op'>=</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>is_empty</span>();
@ -1718,7 +1739,7 @@
}
} <span class='kw'>else</span> {
<span class='prelude-val'>None</span>
})
} )
.<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(), <span class='op'>|</span><span class='ident'>acc</span>, <span class='kw-2'>ref</span> <span class='ident'>name</span><span class='op'>|</span> <span class='ident'>acc</span> <span class='op'>+</span> <span class='kw-2'>&amp;</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{} &quot;</span>, <span class='ident'>name</span>)[..]);
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>num_req_opts</span> <span class='op'>=</span> <span class='number'>0</span>;
<span class='kw'>let</span> <span class='ident'>req_opts</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>values</span>().<span class='ident'>filter_map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='kw'>if</span> <span class='ident'>x</span>.<span class='ident'>required</span> <span class='op'>||</span> <span class='self'>self</span>.<span class='ident'>matched_reqs</span>.<span class='ident'>contains</span>(<span class='ident'>x</span>.<span class='ident'>name</span>) {
@ -1733,29 +1754,43 @@
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{} &quot;</span>,<span class='ident'>o</span>.<span class='ident'>short</span>.<span class='ident'>unwrap</span>())
},<span class='ident'>o</span>.<span class='ident'>name</span>));
<span class='macro'>print</span><span class='macro'>!</span>(<span class='string'>&quot;{}{} {} {} {} {}&quot;</span>,<span class='ident'>tab</span>, <span class='self'>self</span>.<span class='ident'>bin_name</span>.<span class='ident'>clone</span>().<span class='ident'>unwrap_or</span>(<span class='self'>self</span>.<span class='ident'>name</span>.<span class='ident'>clone</span>()),
<span class='kw'>if</span> <span class='ident'>flags</span> {<span class='string'>&quot;[FLAGS]&quot;</span>} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>},
<span class='kw'>if</span> <span class='ident'>opts</span> {
<span class='comment'>// usage.push_str(tab);</span>
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>.<span class='ident'>bin_name</span>.<span class='ident'>clone</span>().<span class='ident'>unwrap_or</span>(<span class='self'>self</span>.<span class='ident'>name</span>.<span class='ident'>clone</span>())[..]);
<span class='comment'>// usage.push_str(tab);</span>
<span class='kw'>if</span> <span class='ident'>flags</span> {
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='string'>&quot; [FLAGS]&quot;</span>);
}
<span class='kw'>if</span> <span class='ident'>opts</span> {
<span class='macro'>write</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>usage</span>,<span class='string'>&quot; {}&quot;</span>,
<span class='kw'>if</span> <span class='ident'>num_req_opts</span> <span class='op'>!=</span> <span class='self'>self</span>.<span class='ident'>opts</span>.<span class='ident'>len</span>() <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='ident'>req_opts</span>.<span class='ident'>is_empty</span>() {
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;[OPTIONS] {}&quot;</span>, <span class='kw-2'>&amp;</span><span class='ident'>req_opts</span>[..])
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; [OPTIONS] {}&quot;</span>, <span class='kw-2'>&amp;</span><span class='ident'>req_opts</span>[..])
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>req_opts</span>.<span class='ident'>is_empty</span>() {
<span class='string'>&quot;[OPTIONS]&quot;</span>.<span class='ident'>to_owned</span>()
<span class='string'>&quot; [OPTIONS]&quot;</span>.<span class='ident'>to_owned</span>()
} <span class='kw'>else</span> {
<span class='ident'>req_opts</span>
}
} <span class='kw'>else</span> { <span class='string'>&quot;&quot;</span>.<span class='ident'>to_owned</span>() },
<span class='kw'>if</span> <span class='ident'>pos</span> {
<span class='ident'>req_opts</span>
});
}
<span class='kw'>if</span> <span class='ident'>pos</span> {
<span class='macro'>write</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>usage</span>, <span class='string'>&quot; {}&quot;</span>,
<span class='kw'>if</span> <span class='ident'>num_req_pos</span> <span class='op'>!=</span> <span class='self'>self</span>.<span class='ident'>positionals_idx</span>.<span class='ident'>len</span>() <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='ident'>req_pos</span>.<span class='ident'>is_empty</span>() {
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;[POSITIONAL] {}&quot;</span>, <span class='kw-2'>&amp;</span><span class='ident'>req_pos</span>[..])
<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot; [POSITIONAL] {}&quot;</span>, <span class='kw-2'>&amp;</span><span class='ident'>req_pos</span>[..])
} <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>req_pos</span>.<span class='ident'>is_empty</span>() {
<span class='string'>&quot;[POSITIONAL]&quot;</span>.<span class='ident'>to_owned</span>()
<span class='string'>&quot; [POSITIONAL]&quot;</span>.<span class='ident'>to_owned</span>()
} <span class='kw'>else</span> {
<span class='ident'>req_pos</span>
}
} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>.<span class='ident'>to_owned</span>()},
<span class='kw'>if</span> <span class='ident'>subcmds</span> {<span class='string'>&quot;[SUBCOMMANDS]&quot;</span>} <span class='kw'>else</span> {<span class='string'>&quot;&quot;</span>});
<span class='ident'>req_pos</span>
} );
}
<span class='kw'>if</span> <span class='ident'>subcmds</span> {
<span class='ident'>usage</span>.<span class='ident'>push_str</span>(<span class='string'>&quot; [SUBCOMMANDS]&quot;</span>);
}
}
<span class='ident'>usage</span>.<span class='ident'>shrink_to_fit</span>();
<span class='ident'>usage</span>
}
<span class='kw'>fn</span> <span class='ident'>print_usage</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>more_info</span>: <span class='ident'>bool</span>) {
<span class='macro'>print</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>,<span class='self'>self</span>.<span class='ident'>create_usage</span>());
<span class='kw'>if</span> <span class='ident'>more_info</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;\nFor more information try --help&quot;</span>);
}
@ -1974,6 +2009,7 @@
}
}
}
<span class='ident'>matches</span>.<span class='ident'>usage</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>create_usage</span>());
<span class='self'>self</span>.<span class='ident'>get_matches_from</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>matches</span>, <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>it</span> );
<span class='ident'>matches</span>

View file

@ -285,6 +285,46 @@
<span id="243">243</span>
<span id="244">244</span>
<span id="245">245</span>
<span id="246">246</span>
<span id="247">247</span>
<span id="248">248</span>
<span id="249">249</span>
<span id="250">250</span>
<span id="251">251</span>
<span id="252">252</span>
<span id="253">253</span>
<span id="254">254</span>
<span id="255">255</span>
<span id="256">256</span>
<span id="257">257</span>
<span id="258">258</span>
<span id="259">259</span>
<span id="260">260</span>
<span id="261">261</span>
<span id="262">262</span>
<span id="263">263</span>
<span id="264">264</span>
<span id="265">265</span>
<span id="266">266</span>
<span id="267">267</span>
<span id="268">268</span>
<span id="269">269</span>
<span id="270">270</span>
<span id="271">271</span>
<span id="272">272</span>
<span id="273">273</span>
<span id="274">274</span>
<span id="275">275</span>
<span id="276">276</span>
<span id="277">277</span>
<span id="278">278</span>
<span id="279">279</span>
<span id="280">280</span>
<span id="281">281</span>
<span id="282">282</span>
<span id="283">283</span>
<span id="284">284</span>
<span id="285">285</span>
</pre><pre class='rust '>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
@ -352,7 +392,8 @@
<span class='kw'>pub</span> <span class='ident'>flags</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;a</span> <span class='ident'>str</span>, <span class='ident'>FlagArg</span><span class='op'>&gt;</span>,
<span class='kw'>pub</span> <span class='ident'>opts</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;a</span> <span class='ident'>str</span>, <span class='ident'>OptArg</span><span class='op'>&gt;</span>,
<span class='kw'>pub</span> <span class='ident'>positionals</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='lifetime'>&#39;a</span> <span class='ident'>str</span>, <span class='ident'>PosArg</span><span class='op'>&gt;</span>,
<span class='kw'>pub</span> <span class='ident'>subcommand</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>Box</span><span class='op'>&lt;</span><span class='ident'>SubCommand</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span><span class='op'>&gt;&gt;</span><span class='op'>&gt;</span>
<span class='kw'>pub</span> <span class='ident'>subcommand</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>Box</span><span class='op'>&lt;</span><span class='ident'>SubCommand</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span><span class='op'>&gt;&gt;</span><span class='op'>&gt;</span>,
<span class='kw'>pub</span> <span class='ident'>usage</span>: <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>String</span><span class='op'>&gt;</span>
}
<span class='kw'>impl</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span><span class='op'>&gt;</span> <span class='ident'>ArgMatches</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span><span class='op'>&gt;</span> {
@ -371,7 +412,8 @@
<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='ident'>subcommand</span>: <span class='prelude-val'>None</span>,
<span class='ident'>usage</span>: <span class='prelude-val'>None</span>
}
}
@ -530,6 +572,44 @@
}
<span class='prelude-val'>None</span>
}
<span class='doccomment'>/// If a subcommand was found, returns the name and matches associated with it</span>
<span class='doccomment'>///</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 app_matches = App::new(&quot;myapp&quot;).subcommand(SubCommand::new(&quot;test&quot;)).get_matches();</span>
<span class='doccomment'>/// match app_matches.subcommand() {</span>
<span class='doccomment'>/// (&quot;test&quot;, Some(matches)) =&gt; {}, // test was used</span>
<span class='doccomment'>/// (&quot;config&quot;, Some(matches)) =&gt; {}, // config was used</span>
<span class='doccomment'>/// _ =&gt; {}, // Either no subcommand or one not tested for...</span>
<span class='doccomment'>/// }</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>subcommand</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> (<span class='kw-2'>&amp;</span><span class='ident'>str</span>, <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>ArgMatches</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'>sc</span> ) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>subcommand</span> {
<span class='kw'>return</span> (<span class='kw-2'>&amp;</span><span class='ident'>sc</span>.<span class='ident'>name</span>[..], <span class='prelude-val'>Some</span>(<span class='kw-2'>&amp;</span><span class='ident'>sc</span>.<span class='ident'>matches</span>));
}
(<span class='string'>&quot;&quot;</span>, <span class='prelude-val'>None</span>)
}
<span class='doccomment'>/// Returns a slice of the default usage for the *top level parent App only*</span>
<span class='doccomment'>///</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 app_matches = App::new(&quot;myapp&quot;).subcommand(SubCommand::new(&quot;test&quot;)).get_matches();</span>
<span class='doccomment'>/// println!(&quot;{}&quot;,app_matches.usage().unwrap());</span>
<span class='doccomment'>/// ```</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>usage</span>(<span class='kw-2'>&amp;</span><span class='self'>self</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'>str</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'>u</span> ) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>usage</span> {
<span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>&amp;</span><span class='ident'>u</span>[..]);
}
<span class='prelude-val'>None</span>
}
}
</pre>
</section>

View file

@ -363,18 +363,42 @@
<span id="321">321</span>
<span id="322">322</span>
<span id="323">323</span>
<span id="324">324</span>
<span id="325">325</span>
<span id="326">326</span>
<span id="327">327</span>
<span id="328">328</span>
<span id="329">329</span>
<span id="330">330</span>
<span id="331">331</span>
<span id="332">332</span>
<span id="333">333</span>
<span id="334">334</span>
<span id="335">335</span>
<span id="336">336</span>
<span id="337">337</span>
<span id="338">338</span>
<span id="339">339</span>
</pre><pre class='rust '>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>crate_type</span><span class='op'>=</span> <span class='string'>&quot;lib&quot;</span>]</span>
<span class='comment'>// DOCS</span>
<span class='doccomment'>//! # clap</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ![Travis-CI](https://travis-ci.org/kbknapp/clap-rs.svg?branch=master)</span>
<span class='doccomment'>//! ![Travis-CI](https://travis-ci.org/kbknapp/clap-rs.svg?branch=master) [![Join the chat at https://gitter.im/kbknapp/clap-rs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kbknapp/clap-rs?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge)</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! Command Line Argument Parser written in Rust</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! It is a simple to use and efficient library for parsing command line arguments and subcommands when writing console, or terminal applications.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ## Video Tutorials</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! I&#39;ve been working on a few short video tutorials about using `clap`. They&#39;re located on [youtube](https://www.youtube.com/playlist?list=PLza5oFLQGTl0Bc_EU_pBNcX-rhVqDTRxv). </span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! *Note*: Apologies for the resolution of the first video, it will be updated to a better resolution soon. The other videos have a proper resolution.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ## About</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! You can use `clap` to lay out a list of possible valid command line arguments and subcommands, then let `clap` parse *and validate* the string given by the user at runtime. This means you focus on your applications functionality, not parsing and validating arguments.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! What is different about `clap` from other options available is the very simple almost &#39;Pythonic&#39; style in which you define the valid available arguments for your program, while still giving advanced features. `clap` allows you express complex relationships between arguments in a very simple manner. This means you don&#39;t have to spend tons time learning an entirely new library&#39;s structures and use. The basics of `clap` can be learned almost intuitively.</span>
@ -388,20 +412,20 @@
<span class='doccomment'>//! Below are a few of the features which `clap` supports, full descriptions and usage can be found in the [documentation](http://kbknapp.github.io/clap-rs/docs/clap/index.html) and `examples/` directory</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! * **Auto-generated Help, Version, and Usage information**</span>
<span class='doccomment'>//! - Can be fully, or partially overridden if you wish to roll your own help, version, or usage</span>
<span class='doccomment'>//! - Can optionally be fully, or partially overridden if you want a custom help, version, or usage</span>
<span class='doccomment'>//! * **Flags / Switches** (i.e. bool fields)</span>
<span class='doccomment'>//! - Both short and long versions supported (i.e. `-f` and `--flag` respectively)</span>
<span class='doccomment'>//! - Supports combining short versions (i.e. `-fBgoZ` is the same as `-f -B -g -o -Z`)</span>
<span class='doccomment'>//! - Also supports multiple occurrences (i.e. `myprog -vvv` or `myprog -v -v -v`)</span>
<span class='doccomment'>//! * **Positional Arguments** (i.e. those which are based off an index)</span>
<span class='doccomment'>//! - Also supports multiple values (i.e. `myprog &lt;file&gt;...`</span>
<span class='doccomment'>//! - Supports Specific Value Sets (See below)</span>
<span class='doccomment'>//! - Optionally supports multiple occurrences (i.e. `myprog -vvv` or `myprog -v -v -v`)</span>
<span class='doccomment'>//! * **Positional Arguments** (i.e. those which are based off an index from the program name)</span>
<span class='doccomment'>//! - Optionally supports multiple values (i.e. `myprog &lt;file&gt;...` such as `myprog file1.txt file2.txt` being two values for the same &quot;file&quot; argument)</span>
<span class='doccomment'>//! - Optionally supports Specific Value Sets (See below)</span>
<span class='doccomment'>//! * **Option Arguments** (i.e. those that take values as options)</span>
<span class='doccomment'>//! - Both short and long versions supported (i.e. `-o value` and `--option value` or `--option=value` respectively)</span>
<span class='doccomment'>//! - Also supports multiple values (i.e. `myprog --option &lt;value&gt; --option &lt;othervalue&gt;`)</span>
<span class='doccomment'>//! - Supports Specific Value Sets (See below)</span>
<span class='doccomment'>//! - Optionally supports multiple values (i.e. `myprog --option &lt;value&gt; --option &lt;other_value&gt;`)</span>
<span class='doccomment'>//! - Optionally supports Specific Value Sets (See below)</span>
<span class='doccomment'>//! * **Sub-Commands** (i.e. `git add &lt;file&gt;` where `add` is a sub-command of `git`)</span>
<span class='doccomment'>//! - Support their own sub-arguments, and sub-commands</span>
<span class='doccomment'>//! - Support their own sub-arguments, and sub-commands independant of the parent</span>
<span class='doccomment'>//! - Get their own auto-generated Help, Version, and Usage independant of parent</span>
<span class='doccomment'>//! * **Requirement Rules**: Arguments can optionally define the following types of requirement rules</span>
<span class='doccomment'>//! - Required by default</span>
@ -412,11 +436,11 @@
<span class='doccomment'>//! - Can disallow use of other arguments when present</span>
<span class='doccomment'>//! * **Specific Value Sets**: Positional or Option Arguments can optionally define a specific set of allowed values (i.e. imagine a `--mode` option which may *only* have one of two values `fast` or `slow` such as `--mode fast` or `--mode slow`)</span>
<span class='doccomment'>//! * **Default Values**: Although not specifically provided by `clap` you can achieve this exact functionality from Rust&#39;s `Option&lt;&amp;str&gt;.unwrap_or(&quot;some default&quot;)` method</span>
<span class='doccomment'>//! * **Auto Version from Cargo.toml**: `clap` is fully compatible with Rust&#39;s `env!()` macro for achieving this functionality. See `examples/09_AutoVersion.rs` for how to do this (Thanks to [jhelwig](https://github.com/jhelwig) for pointing this out)</span>
<span class='doccomment'>//! * **Get Version from Cargo.toml**: `clap` is fully compatible with Rust&#39;s `env!()` macro for automatically getting the version from your Cargo.toml. See `examples/09_AutoVersion.rs` for how to do this (Thanks to [jhelwig](https://github.com/jhelwig) for pointing this out)</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ## Quick Example</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! The following shows a quick example of some of the basic functionality of `clap`. For more advanced usage, such as requirements, exclusions, multiple values and occurrences see the [documentation](http://kbknapp.github.io/clap-rs/docs/clap/index.html) or `examples/` directory of this repository.</span>
<span class='doccomment'>//! The following shows a quick example of some of the basic functionality of `clap`. For more advanced usage, such as requirements, exclusions, multiple values and occurrences see the [video tutorials](https://www.youtube.com/playlist?list=PLza5oFLQGTl0Bc_EU_pBNcX-rhVqDTRxv), [documentation](http://kbknapp.github.io/clap-rs/docs/clap/index.html), or `examples/` directory of this repository.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ```rust</span>
<span class='doccomment'>//! // (Full example with comments in examples/01_QuickExample.rs)</span>
@ -424,7 +448,7 @@
<span class='doccomment'>//! use clap::{Arg, App, SubCommand};</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! fn main() {</span>
<span class='doccomment'>//! let matches = App::new(&quot;MyApp&quot;)</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>
@ -433,8 +457,9 @@
<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'>//! .arg(Arg::new(&quot;INPUT&quot;)</span>
<span class='doccomment'>//! .help(&quot;Sets the input file to use&quot;)</span>
<span class='doccomment'>//! .required(true)</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>
@ -442,19 +467,23 @@
<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;controls testing features&quot;)</span>
<span class='doccomment'>//! .version(&quot;1.3&quot;)</span>
<span class='doccomment'>//! .author(&quot;Someone E. &lt;someone_else@other.com&gt;&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;print test information verbosely&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'>//! </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'>//! // Calling .unwrap() is safe here because &quot;INPUT&quot; is required (if &quot;INPUT&quot; wasn&#39;t</span>
<span class='doccomment'>//! // required we could have used an &#39;if let&#39; to conditionally get the value)</span>
<span class='doccomment'>//! println!(&quot;Using input file: {}&quot;, matches.value_of(&quot;INPUT&quot;).unwrap());</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! // Gets a value for config if supplied by user, or defaults to &quot;default.conf&quot;</span>
<span class='doccomment'>//! let config = matches.value_of(&quot;CONFIG&quot;).unwrap_or(&quot;default.conf&quot;);</span>
<span class='doccomment'>//! println!(&quot;Value for config: {}&quot;, config);</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! // Vary the output based on how many times the user used the &quot;debug&quot; flag</span>
<span class='doccomment'>//! // (i.e. &#39;myapp -d -d -d&#39; or &#39;myapp -ddd&#39; vs &#39;myapp -d&#39; </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>
@ -462,7 +491,7 @@
<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 let Some(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 verbosely...&quot;);</span>
<span class='doccomment'>//! } else {</span>
@ -474,33 +503,35 @@
<span class='doccomment'>//! }</span>
<span class='doccomment'>//! ```</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! If you were to compile the above program and run it with the flag `--help` or `-h` (or `help` subcommand, since we defined `test` as a subcommand) the following output woud be presented</span>
<span class='doccomment'>//! If you were to compile the above program and run it with the flag `--help` or `-h` (or `help` subcommand, since we defined `test` as a subcommand) the following would be output</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ```sh</span>
<span class='doccomment'>//! $ myprog --help</span>
<span class='doccomment'>//! MyApp 1.0</span>
<span class='doccomment'>//! $ myapp --help</span>
<span class='doccomment'>//! myapp 1.0</span>
<span class='doccomment'>//! Kevin K. &lt;kbknapp@gmail.com&gt;</span>
<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] &lt;INPUT&gt; [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'>//! -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=CONFIG Sets a custom config file</span>
<span class='doccomment'>//! -c, --config=CONFIG 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'>//! INPUT The input file to use</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! SUBCOMMANDS:</span>
<span class='doccomment'>//! help Prints this message</span>
<span class='doccomment'>//! test Controls testing features</span>
<span class='doccomment'>//! help Prints this message</span>
<span class='doccomment'>//! test Controls testing features</span>
<span class='doccomment'>//! ```</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! *NOTE:* You could also run `myapp test --help` to see similar output and options for the `test` subcommand.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ## Installation</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! Add `clap` as a dependecy in your `Cargo.toml` file to use from crates.io:</span>
@ -518,65 +549,66 @@
<span class='doccomment'>//! </span>
<span class='doccomment'>//! Add `extern crate clap;` to your crate root.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! Define a list of valid arguments for your program (see the documentation or examples/ directory)</span>
<span class='doccomment'>//! Define a list of valid arguments for your program (see the [documentation](https://kbknapp.github.io/clap-rs/index.html) or `examples/` directory of this repo)</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! Then run `cargo build` or `cargo update &amp;&amp; cargo build` for your project.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ## More Information</span>
<span class='doccomment'>//! ### More Information</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! You can find complete documentation on the [github-pages site](http://kbknapp.github.io/clap-rs/docs/clap/index.html) for this project.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! You can also find full usage examples in the `examples/` directory of this repo.</span>
<span class='doccomment'>//! You can also find usage examples in the `examples/` directory of this repo.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ## How to build and contribute</span>
<span class='doccomment'>//! ## How to Contribute</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! Contributions are always welcome! And there is a multitude of ways in which you can help depending on what you like to do, or are good at. Anything from documentation, code cleanup, issue completion, new features, you name it, even filing issues is contributing and greatly appreciated!</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! 1. Fork the project</span>
<span class='doccomment'>//! 2. Clone your fork (`git clone https://github.com/$USER/clap-rs &amp;&amp; cd clap-rs`)</span>
<span class='doccomment'>//! 3. Create new branch (`git checkout -b your-branch`)</span>
<span class='doccomment'>//! 4. Make your changes, and commit (`git commit -am &quot;your message&quot;`)</span>
<span class='doccomment'>//! 2. Clone your fork (`git clone https://github.com/$YOUR_USERNAME/clap-rs &amp;&amp; cd clap-rs`)</span>
<span class='doccomment'>//! 3. Create new branch (`git checkout -b new-branch`)</span>
<span class='doccomment'>//! 4. Make your changes, and commit (`git commit -am &quot;your message&quot;`) (I try to use a [conventional](https://github.com/ajoslin/conventional-changelog/blob/master/CONVENTIONS.md) changelog format so I can update it using [clog](https://github.com/thoughtram/clog))</span>
<span class='doccomment'>//! 5. If applicable, run the tests (See below)</span>
<span class='doccomment'>//! 6. Push your changes back to your fork (`git push origin your-branch`)</span>
<span class='doccomment'>//! 7. Create a pull request! (You can create the pull request right away, and we&#39;ll merge when read. This a good way to discuss proposed changes)</span>
<span class='doccomment'>//! 7. Create a pull request! (You can also create the pull request right away, and we&#39;ll merge when ready. This a good way to discuss proposed changes.) </span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! Another really great way to help is if you find an interesting, or helpful way in which to use `clap` you can either add it to the `examples/` directory, or file an issue and tell me. I&#39;m all about giving credit where credit is due :)</span>
<span class='doccomment'>//! Another really great way to help is if you find an interesting, or helpful way in which to use `clap`. You can either add it to the `examples/` directory, or file an issue and tell me. I&#39;m all about giving credit where credit is due :)</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ### Running the tests</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! If contributing, you can run the tests as follows (assuming you&#39;ve already cloned the repo to `clap-rs/`</span>
<span class='doccomment'>//! If contributing, you can run the tests as follows (assuming you&#39;ve cloned the repo to `clap-rs/`</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ```</span>
<span class='doccomment'>//! cd clap-rs</span>
<span class='doccomment'>//! cargo test</span>
<span class='doccomment'>//! cd claptests</span>
<span class='doccomment'>//! make test</span>
<span class='doccomment'>//! cd clap-rs &amp;&amp; cargo test</span>
<span class='doccomment'>//! cd clap-tests &amp;&amp; make test</span>
<span class='doccomment'>//! ```</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ### Building the documentation</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! If the changes require re-building the documentation, run this instead of `cargo doc` to generate the proper module docstring:</span>
<span class='doccomment'>//! If your changes require re-building the documentation, run this instead of `cargo doc` to generate the proper module docstring:</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ```</span>
<span class='doccomment'>//! make doc</span>
<span class='doccomment'>//! cd clap-rs &amp;&amp; make doc</span>
<span class='doccomment'>//! ```</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! Then browse to `clap-rs/docs/clap/index.html` in your web-browser of choice to check it out. You can then create a PR on the `gh-pages` branch</span>
<span class='doccomment'>//! Then browse to `clap-rs/docs/clap/index.html` in your web-browser of choice to check it out.</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ### Goals</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! There are a few goals of `clap` that I&#39;d like to maintain. If your proposed changes break, or go against any of these goals we&#39;ll discuss the changes further before merging (but will *not* be ignored, all contributes are welcome!). These are by no means hard-and-fast rules, as I&#39;m no expert and break them myself from time to time (even if just by mistake or ignorance :P).</span>
<span class='doccomment'>//! There are a few goals of `clap` that I&#39;d like to maintain throughout contributions. If your proposed changes break, or go against any of these goals we&#39;ll discuss the changes further before merging (but will *not* be ignored, all contributes are welcome!). These are by no means hard-and-fast rules, as I&#39;m no expert and break them myself from time to time (even if by mistake or ignorance :P).</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! * Remain backwards compatible when possible</span>
<span class='doccomment'>//! - If backwards compatibility *must* be broken, use deprecation warnings if at all possible before removing legacy code</span>
<span class='doccomment'>//! - This does not apply for security concerns</span>
<span class='doccomment'>//! * Parse arguments quickly</span>
<span class='doccomment'>//! - Parsing of arguments shouldn&#39;t slow down usage of the main program</span>
<span class='doccomment'>//! - This is also true of generating help and usage information</span>
<span class='doccomment'>//! * Try not to be cognizant of memory usage</span>
<span class='doccomment'>//! - This is also true of generating help and usage information (although *slightly* less stringent, as the program is about to exit)</span>
<span class='doccomment'>//! * Try to be cognizant of memory usage</span>
<span class='doccomment'>//! - Once parsing is complete, the memory footprint of `clap` should be low since the main program is the star of the show</span>
<span class='doccomment'>//! * `panic!` on *developer* error, exit gracefully on *end-user* error</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! ## License</span>
<span class='doccomment'>//! </span>
<span class='doccomment'>//! `clap` is licensed under the MIT license. Please the LICENSE-MIT file in this repository for more information.</span>
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>args</span>::{<span class='ident'>Arg</span>, <span class='ident'>SubCommand</span>, <span class='ident'>ArgMatches</span>};
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>app</span>::<span class='ident'>App</span>;