mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
Rebuild docs after tab->space change
This commit is contained in:
parent
20de5b339e
commit
bc94d11b03
12 changed files with 1297 additions and 1297 deletions
|
@ -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."]]});
|
|
@ -45,95 +45,95 @@
|
||||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||||
</span><a id='src-0' href='../src/clap/lib.rs.html#1-155'>[src]</a></span></h1>
|
</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
|
<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.
|
<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.
|
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 'for free' by parsing the list of possible valid arguments lazily at runtime.
|
Also, <code>clap</code> provides the traditional version and help switches 'for free' by parsing the list of possible valid arguments lazily at runtime.
|
||||||
i.e. only when it's been determined that the user wants or needs to see the help and version information.</p>
|
i.e. only when it'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
|
<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>
|
<h1 id="example" class='section-header'><a
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
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='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'>"MyApp"</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'>"MyApp"</span>)
|
||||||
.<span class='ident'>version</span>(<span class='string'>"1.0"</span>)
|
.<span class='ident'>version</span>(<span class='string'>"1.0"</span>)
|
||||||
.<span class='ident'>author</span>(<span class='string'>"Kevin K. <kbknapp@gmail.com>"</span>)
|
.<span class='ident'>author</span>(<span class='string'>"Kevin K. <kbknapp@gmail.com>"</span>)
|
||||||
.<span class='ident'>about</span>(<span class='string'>"Does awesome things"</span>)
|
.<span class='ident'>about</span>(<span class='string'>"Does awesome things"</span>)
|
||||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>)
|
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>)
|
||||||
.<span class='ident'>short</span>(<span class='string'>"c"</span>)
|
.<span class='ident'>short</span>(<span class='string'>"c"</span>)
|
||||||
.<span class='ident'>long</span>(<span class='string'>"config"</span>)
|
.<span class='ident'>long</span>(<span class='string'>"config"</span>)
|
||||||
.<span class='ident'>help</span>(<span class='string'>"Sets a custom config file"</span>)
|
.<span class='ident'>help</span>(<span class='string'>"Sets a custom config file"</span>)
|
||||||
.<span class='ident'>takes_value</span>(<span class='boolval'>true</span>))
|
.<span class='ident'>takes_value</span>(<span class='boolval'>true</span>))
|
||||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"output"</span>)
|
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"output"</span>)
|
||||||
.<span class='ident'>help</span>(<span class='string'>"Sets an optional output file"</span>)
|
.<span class='ident'>help</span>(<span class='string'>"Sets an optional output file"</span>)
|
||||||
.<span class='ident'>index</span>(<span class='number'>1</span>))
|
.<span class='ident'>index</span>(<span class='number'>1</span>))
|
||||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"debug"</span>)
|
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"debug"</span>)
|
||||||
.<span class='ident'>short</span>(<span class='string'>"d"</span>)
|
.<span class='ident'>short</span>(<span class='string'>"d"</span>)
|
||||||
.<span class='ident'>multiple</span>(<span class='boolval'>true</span>)
|
.<span class='ident'>multiple</span>(<span class='boolval'>true</span>)
|
||||||
.<span class='ident'>help</span>(<span class='string'>"Turn debugging information on"</span>))
|
.<span class='ident'>help</span>(<span class='string'>"Turn debugging information on"</span>))
|
||||||
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"test"</span>)
|
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"test"</span>)
|
||||||
.<span class='ident'>about</span>(<span class='string'>"Has test sub functionality"</span>)
|
.<span class='ident'>about</span>(<span class='string'>"Has test sub functionality"</span>)
|
||||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"verbose"</span>)
|
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"verbose"</span>)
|
||||||
.<span class='ident'>short</span>(<span class='string'>"v"</span>)
|
.<span class='ident'>short</span>(<span class='string'>"v"</span>)
|
||||||
.<span class='ident'>help</span>(<span class='string'>"Display verbose information"</span>)))
|
.<span class='ident'>help</span>(<span class='string'>"Display verbose information"</span>)))
|
||||||
.<span class='ident'>get_matches</span>();
|
.<span class='ident'>get_matches</span>();
|
||||||
|
|
||||||
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>o</span>) <span class='op'>=</span> <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>"output"</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'>"output"</span>) {
|
||||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Value for output: {}"</span>, <span class='ident'>o</span>);
|
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Value for output: {}"</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'>"config"</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'>"config"</span>) {
|
||||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Value for config: {}"</span>, <span class='ident'>c</span>);
|
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Value for config: {}"</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'>"debug"</span>) {
|
<span class='kw'>match</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>"debug"</span>) {
|
||||||
<span class='number'>0</span> <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode is off"</span>),
|
<span class='number'>0</span> <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode is off"</span>),
|
||||||
<span class='number'>1</span> <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode is kind of on"</span>),
|
<span class='number'>1</span> <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode is kind of on"</span>),
|
||||||
<span class='number'>2</span> <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode is on"</span>),
|
<span class='number'>2</span> <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode is on"</span>),
|
||||||
<span class='number'>3</span> <span class='op'>|</span> _ <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Don't be crazy"</span>),
|
<span class='number'>3</span> <span class='op'>|</span> _ <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Don't be crazy"</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'>"test"</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'>"test"</span>) {
|
||||||
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>is_present</span>(<span class='string'>"verbose"</span>) {
|
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>is_present</span>(<span class='string'>"verbose"</span>) {
|
||||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Printing verbose test info..."</span>);
|
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Printing verbose test info..."</span>);
|
||||||
} <span class='kw'>else</span> {
|
} <span class='kw'>else</span> {
|
||||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Not printing regular test info..."</span>);
|
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Not printing regular test info..."</span>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='comment'>// more porgram logic goes here...</span>
|
<span class='comment'>// more porgram logic goes here...</span>
|
||||||
</pre>
|
</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>
|
<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
|
<pre><code class="language-sh">$ myprog --help
|
||||||
MyApp 1.0
|
MyApp 1.0
|
||||||
Kevin K. <kbknapp@gmail.com>
|
Kevin K. <kbknapp@gmail.com>
|
||||||
Does awesome things
|
Does awesome things
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]
|
MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]
|
||||||
|
|
||||||
FLAGS:
|
FLAGS:
|
||||||
-d Turn debugging information on
|
-d Turn debugging information on
|
||||||
-h,--help Prints this message
|
-h,--help Prints this message
|
||||||
-v,--version Prints version information
|
-v,--version Prints version information
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-c,--config <config> Sets a custom config file
|
-c,--config <config> Sets a custom config file
|
||||||
|
|
||||||
POSITIONAL ARGUMENTS:
|
POSITIONAL ARGUMENTS:
|
||||||
output Sets an optional output file
|
output Sets an optional output file
|
||||||
|
|
||||||
SUBCOMMANDS:
|
SUBCOMMANDS:
|
||||||
help Prints this message
|
help Prints this message
|
||||||
test Has test sub-functionality
|
test Has test sub-functionality
|
||||||
</code></pre>
|
</code></pre>
|
||||||
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
||||||
<table>
|
<table>
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
<td><a class='stability Unmarked' title='No stability level'></a><a class='struct' href='struct.App.html'
|
<td><a class='stability Unmarked' title='No stability level'></a><a class='struct' href='struct.App.html'
|
||||||
title='clap::App'>App</a></td>
|
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
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
|
@ -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. "]]});
|
|
@ -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><&'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>,
|
pub about: <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>,
|
||||||
// some fields omitted
|
// some fields omitted
|
||||||
}</pre><div class='docblock'><p>Used to create a representation of the program and all possible command line arguments
|
}</pre><div class='docblock'><p>Used to create a representation of the program and all possible command line arguments
|
||||||
for parsing at runtime.</p>
|
for parsing at runtime.</p>
|
||||||
|
|
||||||
<p>Stores a list of all posisble arguments, as well as information displayed to the user such as
|
<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>
|
<h1 id="example" class='section-header'><a
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
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'>"myprog"</span>)
|
<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'>"myprog"</span>)
|
||||||
.<span class='ident'>author</span>(<span class='string'>"Me, me@mail.com"</span>)
|
.<span class='ident'>author</span>(<span class='string'>"Me, me@mail.com"</span>)
|
||||||
.<span class='ident'>version</span>(<span class='string'>"1.0.2"</span>)
|
.<span class='ident'>version</span>(<span class='string'>"1.0.2"</span>)
|
||||||
.<span class='ident'>about</span>(<span class='string'>"Explains in brief what the program does"</span>)
|
.<span class='ident'>about</span>(<span class='string'>"Explains in brief what the program does"</span>)
|
||||||
.<span class='ident'>arg</span>(
|
.<span class='ident'>arg</span>(
|
||||||
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"in_file"</span>).<span class='ident'>index</span>(<span class='number'>1</span>)
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"in_file"</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='comment'>// Add other possible command line argument options here...</span>
|
||||||
)
|
)
|
||||||
.<span class='ident'>get_matches</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>
|
</pre>
|
||||||
</div><h2 class='fields'>Fields</h2>
|
</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>
|
<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>) -> <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
|
</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>) -> <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>
|
<div class='docblock'><p>Adds an argument to the list of valid possibilties</p>
|
||||||
|
|
||||||
<p># Example</p>
|
<h1 id="example" class='section-header'><a
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
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'>"config"</span>)
|
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>)
|
||||||
.<span class='ident'>short</span>(<span class='string'>"c"</span>)
|
.<span class='ident'>short</span>(<span class='string'>"c"</span>)
|
||||||
<span class='comment'>// Additional argument configuration goes here...</span>
|
<span class='comment'>// Additional argument configuration goes here...</span>
|
||||||
)
|
)
|
||||||
</pre>
|
</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><<a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>>) -> <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
|
</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><<a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a>>) -> <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>
|
<div class='docblock'><p>Adds multiple arguments to the list of valid possibilties</p>
|
||||||
|
|
||||||
<p># Example</p>
|
<h1 id="example" class='section-header'><a
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
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'>"config"</span>).<span class='ident'>short</span>(<span class='string'>"c"</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'>"config"</span>).<span class='ident'>short</span>(<span class='string'>"c"</span>),
|
||||||
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"debug"</span>).<span class='ident'>short</span>(<span class='string'>"d"</span>)])
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"debug"</span>).<span class='ident'>short</span>(<span class='string'>"d"</span>)])
|
||||||
</pre>
|
</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>) -> <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
|
</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>) -> <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
|
<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
|
are effectively sub apps, because they can contain their own arguments
|
||||||
and subcommands. They also function just like apps, in that they get their
|
and subcommands. They also function just like apps, in that they get their
|
||||||
own auto generated help and version switches.</p>
|
own auto generated help and version switches.</p>
|
||||||
|
|
||||||
<p># Example</p>
|
<h1 id="example" class='section-header'><a
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
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'>"config"</span>)
|
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>)
|
||||||
.<span class='ident'>about</span>(<span class='string'>"Controls configuration features"</span>)
|
.<span class='ident'>about</span>(<span class='string'>"Controls configuration features"</span>)
|
||||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config_file"</span>)
|
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config_file"</span>)
|
||||||
.<span class='ident'>index</span>(<span class='number'>1</span>)
|
.<span class='ident'>index</span>(<span class='number'>1</span>)
|
||||||
.<span class='ident'>help</span>(<span class='string'>"Configuration file to use"</span>)))
|
.<span class='ident'>help</span>(<span class='string'>"Configuration file to use"</span>)))
|
||||||
<span class='comment'>// Additional subcommand configuration goes here, such as arguments...</span>
|
<span class='comment'>// Additional subcommand configuration goes here, such as arguments...</span>
|
||||||
)
|
)
|
||||||
</pre>
|
</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><<a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>>) -> <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
|
</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><<a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a>>) -> <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>
|
<div class='docblock'><p>Adds multiple subcommands to the list of valid possibilties</p>
|
||||||
|
|
||||||
<p># Example</p>
|
<h1 id="example" class='section-header'><a
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
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'>subcommands</span>( <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||||
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>).<span class='ident'>about</span>(<span class='string'>"Controls configuration functionality"</span>)
|
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>).<span class='ident'>about</span>(<span class='string'>"Controls configuration functionality"</span>)
|
||||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config_file"</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'>"config_file"</span>).<span class='ident'>index</span>(<span class='number'>1</span>)),
|
||||||
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"debug"</span>).<span class='ident'>about</span>(<span class='string'>"Controls debug functionality"</span>)])
|
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"debug"</span>).<span class='ident'>about</span>(<span class='string'>"Controls debug functionality"</span>)])
|
||||||
</pre>
|
</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) -> <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a></code></h4>
|
</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) -> <a class='struct' href='../clap/struct.ArgMatches.html' title='clap::ArgMatches'>ArgMatches</a></code></h4>
|
||||||
</div></section>
|
</div></section>
|
||||||
|
|
|
@ -170,16 +170,16 @@ arguments, they do not need to be set for each.</p>
|
||||||
</pre>
|
</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><&'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>) -> <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
|
</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><&'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>) -> <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,
|
<div class='docblock'><p>Sets a mutually exclusive arguments by names. I.e. when using this argument,
|
||||||
the following argument can't be present.</p>
|
the following argument can't be present.</p>
|
||||||
|
|
||||||
<p><strong>NOTE:</strong> Mutually exclusive rules take precedence over being required
|
<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
|
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>
|
arguments, they do not need to be set for each.</p>
|
||||||
|
|
||||||
<p>Example:</p>
|
<p>Example:</p>
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
<pre id='rust-example-rendered' class='rust '>
|
||||||
.<span class='ident'>mutually_excludes_all</span>(
|
.<span class='ident'>mutually_excludes_all</span>(
|
||||||
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"debug"</span>, <span class='string'>"input"</span>])
|
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"debug"</span>, <span class='string'>"input"</span>])
|
||||||
</pre>
|
</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: &'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
|
</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: &'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <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
|
<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>
|
</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><&'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>) -> <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
|
</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><&'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>) -> <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
|
<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
|
<p><strong>NOTE:</strong> Mutually exclusive rules take precedence over being required
|
||||||
by default. </p>
|
by default. </p>
|
||||||
|
|
||||||
<p>Example:</p>
|
<p>Example:</p>
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
<pre id='rust-example-rendered' class='rust '>
|
||||||
.<span class='ident'>requires_all</span>(
|
.<span class='ident'>requires_all</span>(
|
||||||
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"debug"</span>, <span class='string'>"input"</span>])
|
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"debug"</span>, <span class='string'>"input"</span>])
|
||||||
</pre>
|
</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>) -> <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
|
</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>) -> <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>
|
<div class='docblock'><p>Specifies that the argument takes an additional value at run time.</p>
|
||||||
|
|
|
@ -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>
|
}</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
|
<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 "sub apps" and contain all the same possibilities (such as
|
their program. SubCommands are treated like "sub apps" and contain all the same possibilities (such as
|
||||||
their own arguments and subcommands).</p>
|
their own arguments and subcommands).</p>
|
||||||
|
|
||||||
<p># Example</p>
|
<h1 id="example" class='section-header'><a
|
||||||
<pre id='rust-example-rendered' class='rust '>
|
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'>"conifg"</span>)
|
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"conifg"</span>)
|
||||||
.<span class='ident'>about</span>(<span class='string'>"Used for configuration"</span>)
|
.<span class='ident'>about</span>(<span class='string'>"Used for configuration"</span>)
|
||||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config_file"</span>)
|
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config_file"</span>)
|
||||||
.<span class='ident'>help</span>(<span class='string'>"The configuration file to use"</span>)
|
.<span class='ident'>help</span>(<span class='string'>"The configuration file to use"</span>)
|
||||||
.<span class='ident'>index</span>(<span class='number'>1</span>))
|
.<span class='ident'>index</span>(<span class='number'>1</span>))
|
||||||
</pre>
|
</pre>
|
||||||
</div><h2 class='fields'>Fields</h2>
|
</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: &'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <a class='struct' href='../clap/struct.App.html' title='clap::App'>App</a></code></h4>
|
<table><tr><td id='structfield.name'><a class='stability Unmarked' title='No stability level'></a><code>name</code></td><td></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: &'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <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
|
@ -400,7 +400,7 @@
|
||||||
<span class='doccomment'>/// .help("Provides a config file to myprog")</span>
|
<span class='doccomment'>/// .help("Provides a config file to myprog")</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Arg</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>,
|
<span class='kw'>pub</span> <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'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'>/// The short version (i.e. single character) of the argument, no preceding `-`</span>
|
||||||
<span class='doccomment'>/// **NOTE:** `short` is mutually exclusive with `index`</span>
|
<span class='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='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='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='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'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>>></span>,
|
<span class='kw'>pub</span> <span class='ident'>blacklist</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>>></span>,
|
||||||
<span class='doccomment'>/// A list of names of other arguments that are *required* to be used when </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='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'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>>></span>
|
<span class='kw'>pub</span> <span class='ident'>requires</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>>></span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='kw'>impl</span> <span class='ident'>Arg</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'>/// 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'>/// 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'>/// whether or not the argument was used at runtime. </span>
|
||||||
<span class='doccomment'>///</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'>/// **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'>/// 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'>/// be displayed when the user prints the usage/help information of the program.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .arg(</span>
|
<span class='doccomment'>/// # .arg(</span>
|
||||||
<span class='doccomment'>/// Arg::new("conifg")</span>
|
<span class='doccomment'>/// Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// # .short("c")</span>
|
<span class='doccomment'>/// # .short("c")</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>n</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Arg</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Arg</span> {
|
||||||
<span class='ident'>Arg</span> {
|
<span class='ident'>Arg</span> {
|
||||||
<span class='ident'>name</span>: <span class='ident'>n</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'>short</span>: <span class='prelude-val'>None</span>,
|
||||||
<span class='ident'>long</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'>help</span>: <span class='prelude-val'>None</span>,
|
||||||
<span class='ident'>required</span>: <span class='boolval'>false</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'>takes_value</span>: <span class='boolval'>false</span>,
|
||||||
<span class='ident'>multiple</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'>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'>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='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'>/// Sets the short version of the argument without the preceding `-`.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</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'>/// 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'>/// 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'>/// will not asign those to the displaying of version or help.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// **NOTE:** Any leading `-` characters will be stripped, and only the first</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'>/// 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'>/// mistakenly sets the short to `-o` or the like.</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .arg(</span>
|
<span class='doccomment'>/// # .arg(</span>
|
||||||
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .short("c")</span>
|
<span class='doccomment'>/// .short("c")</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>short</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Arg</span> {
|
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>short</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></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'>'-'</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'>'-'</span>)
|
||||||
.<span class='ident'>char_at</span>(<span class='number'>0</span>));
|
.<span class='ident'>char_at</span>(<span class='number'>0</span>));
|
||||||
<span class='self'>self</span>
|
<span class='self'>self</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='doccomment'>/// Sets the long version of the argument without the preceding `--`.</span>
|
<span class='doccomment'>/// Sets the long version of the argument without the preceding `--`.</span>
|
||||||
<span class='doccomment'>///</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'>/// 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'>/// 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'>/// 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'>/// so manually.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// **NOTE:** Any leading `-` characters will be stripped i.e. for </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'>/// when the user mistakenly sets the short to `--out` or the like.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .arg(</span>
|
<span class='doccomment'>/// # .arg(</span>
|
||||||
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .long("config")</span>
|
<span class='doccomment'>/// .long("config")</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>long</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>l</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Arg</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></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'>'-'</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'>'-'</span>));
|
||||||
<span class='self'>self</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'>/// 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'>/// when they print the usage/help information. </span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .arg(</span>
|
<span class='doccomment'>/// # .arg(</span>
|
||||||
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .help("The config file used by the myprog")</span>
|
<span class='doccomment'>/// .help("The config file used by the myprog")</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>help</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>h</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Arg</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></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='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='self'>self</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='doccomment'>/// Sets whether or not the argument is required by default. Required by</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'>/// 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'>/// been evaluated. Mutually exclusive rules take precedence over being required</span>
|
||||||
<span class='doccomment'>/// by default.</span>
|
<span class='doccomment'>/// by default.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// **NOTE:** Flags (i.e. not positional, or arguments that take values)</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'>/// cannot be required by default.</span>
|
||||||
<span class='doccomment'>/// when they print the usage/help information. </span>
|
<span class='doccomment'>/// when they print the usage/help information. </span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .arg(</span>
|
<span class='doccomment'>/// # .arg(</span>
|
||||||
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .required(true)</span>
|
<span class='doccomment'>/// .required(true)</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>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'>-></span> <span class='ident'>Arg</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'>-></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='ident'>required</span> <span class='op'>=</span> <span class='ident'>r</span>;
|
||||||
<span class='self'>self</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'>/// Sets a mutually exclusive argument by name. I.e. when using this argument, </span>
|
||||||
<span class='doccomment'>/// the following argument can't be present.</span>
|
<span class='doccomment'>/// the following argument can't be present.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</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'>/// 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'>/// arguments, they do not need to be set for each.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let myprog = App::new("myprog").arg(Arg::new("conifg")</span>
|
<span class='doccomment'>/// # let myprog = App::new("myprog").arg(Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .mutually_excludes("debug")</span>
|
<span class='doccomment'>/// .mutually_excludes("debug")</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mutually_excludes</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Arg</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></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'>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='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>name</span>);
|
||||||
} <span class='kw'>else</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='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='self'>self</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='doccomment'>/// Sets a mutually exclusive arguments by names. I.e. when using this argument, </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't be present.</span>
|
<span class='doccomment'>/// the following argument can't be present.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</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'>/// 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'>/// arguments, they do not need to be set for each.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let myprog = App::new("myprog").arg(Arg::new("conifg")</span>
|
<span class='doccomment'>/// # let myprog = App::new("myprog").arg(Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .mutually_excludes_all(</span>
|
<span class='doccomment'>/// .mutually_excludes_all(</span>
|
||||||
<span class='doccomment'>/// vec!["debug", "input"])</span>
|
<span class='doccomment'>/// vec!["debug", "input"])</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>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'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Arg</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'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></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'>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='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='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>n</span>);
|
||||||
}
|
}
|
||||||
} <span class='kw'>else</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='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='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'>/// 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'>/// using this argument, the following argument *must* be present.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
|
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let myprog = App::new("myprog").arg(Arg::new("conifg")</span>
|
<span class='doccomment'>/// # let myprog = App::new("myprog").arg(Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .requires("debug")</span>
|
<span class='doccomment'>/// .requires("debug")</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>requires</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Arg</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></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'>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='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>name</span>);
|
||||||
} <span class='kw'>else</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='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='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'>/// 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'>/// using this argument, the following arguments *must* be present.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
|
<span class='doccomment'>/// **NOTE:** Mutually exclusive rules take precedence over being required</span>
|
||||||
<span class='doccomment'>/// by default. </span>
|
<span class='doccomment'>/// by default. </span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let myprog = App::new("myprog").arg(Arg::new("conifg")</span>
|
<span class='doccomment'>/// # let myprog = App::new("myprog").arg(Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .requires_all(</span>
|
<span class='doccomment'>/// .requires_all(</span>
|
||||||
<span class='doccomment'>/// vec!["debug", "input"])</span>
|
<span class='doccomment'>/// vec!["debug", "input"])</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>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'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Arg</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'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></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'>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='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='ident'>vec</span>.<span class='ident'>push</span>(<span class='ident'>n</span>);
|
||||||
}
|
}
|
||||||
} <span class='kw'>else</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='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='self'>self</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='doccomment'>/// Specifies that the argument takes an additional value at run time.</span>
|
<span class='doccomment'>/// Specifies that the argument takes an additional value at run time.</span>
|
||||||
<span class='doccomment'>/// </span>
|
<span class='doccomment'>/// </span>
|
||||||
<span class='doccomment'>/// **NOTE:** When setting this to `true` the `name` of the argument</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'>/// will be used when printing the help/usage information to the user. </span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .arg(</span>
|
<span class='doccomment'>/// # .arg(</span>
|
||||||
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .takes_value(true)</span>
|
<span class='doccomment'>/// .takes_value(true)</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>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'>-></span> <span class='ident'>Arg</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'>-></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='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='ident'>takes_value</span> <span class='op'>=</span> <span class='ident'>tv</span>;
|
||||||
<span class='self'>self</span>
|
<span class='self'>self</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='doccomment'>/// Specifies the index of a positional argument starting at 1.</span>
|
<span class='doccomment'>/// Specifies the index of a positional argument starting at 1.</span>
|
||||||
<span class='doccomment'>/// </span>
|
<span class='doccomment'>/// </span>
|
||||||
<span class='doccomment'>/// **NOTE:** When setting this, any `short` or `long` values you set</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'>/// 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'>/// Also, the name will be used when printing the help/usage information </span>
|
||||||
<span class='doccomment'>/// to the user. </span>
|
<span class='doccomment'>/// to the user. </span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .arg(</span>
|
<span class='doccomment'>/// # .arg(</span>
|
||||||
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
<span class='doccomment'>/// # Arg::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .index(1)</span>
|
<span class='doccomment'>/// .index(1)</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>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'>-></span> <span class='ident'>Arg</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'>-></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'>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'><</span> <span class='number'>1</span> { <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"Argument index must start at 1"</span>); }
|
<span class='kw'>if</span> <span class='ident'>idx</span> <span class='op'><</span> <span class='number'>1</span> { <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"Argument index must start at 1"</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='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='self'>self</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='doccomment'>/// Specifies if the flag may appear more than once such as for multiple debugging</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'>/// 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'>/// 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'>/// of a particular flag at runtime.</span>
|
||||||
<span class='doccomment'>/// </span>
|
<span class='doccomment'>/// </span>
|
||||||
<span class='doccomment'>/// **NOTE:** When setting this, any `takes_value` or `index` values you set</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'>/// are ignored as flags cannot have a values or an `index`.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// Example:</span>
|
<span class='doccomment'>/// Example:</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .arg(</span>
|
<span class='doccomment'>/// # .arg(</span>
|
||||||
<span class='doccomment'>/// # Arg::new("debug")</span>
|
<span class='doccomment'>/// # Arg::new("debug")</span>
|
||||||
<span class='doccomment'>/// .multiple(true)</span>
|
<span class='doccomment'>/// .multiple(true)</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>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'>-></span> <span class='ident'>Arg</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'>-></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'>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='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='ident'>multiple</span> <span class='op'>=</span> <span class='ident'>multi</span>;
|
||||||
<span class='self'>self</span>
|
<span class='self'>self</span>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -325,15 +325,15 @@
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||||
<span class='doccomment'>/// let matches = App::new("myprog").get_matches();</span>
|
<span class='doccomment'>/// let matches = App::new("myprog").get_matches();</span>
|
||||||
<span class='doccomment'>/// ```</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>ArgMatches</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>ArgMatches</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'>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'>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'>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'>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='doccomment'>/// Gets the value of a specific option or positional argument (i.e. an argument that takes</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't present at runtime</span>
|
<span class='doccomment'>/// an additional value at runtime). If the option wasn't present at runtime</span>
|
||||||
|
@ -348,19 +348,19 @@
|
||||||
<span class='doccomment'>/// println!("Value for output: {}", o);</span>
|
<span class='doccomment'>/// println!("Value for output: {}", o);</span>
|
||||||
<span class='doccomment'>/// }</span>
|
<span class='doccomment'>/// }</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'>&</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>String</span><span class='op'>></span> {
|
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>value_of</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>String</span><span class='op'>></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'>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'>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'>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'>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'>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'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>v</span>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<span class='prelude-val'>None</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'>/// Checks if a flag was argument was supplied at runtime. **DOES NOT** work for</span>
|
||||||
<span class='doccomment'>/// option or positional arguments (use `.value_of()` instead)</span>
|
<span class='doccomment'>/// option or positional arguments (use `.value_of()` instead)</span>
|
||||||
|
@ -375,7 +375,7 @@
|
||||||
<span class='doccomment'>/// println!("The output argument was used!");</span>
|
<span class='doccomment'>/// println!("The output argument was used!");</span>
|
||||||
<span class='doccomment'>/// }</span>
|
<span class='doccomment'>/// }</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'>&</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></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'>&</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></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='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>; }
|
<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='kw'>return</span> <span class='boolval'>true</span>;
|
||||||
}
|
}
|
||||||
<span class='boolval'>false</span>
|
<span class='boolval'>false</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='doccomment'>/// Checks the number of occurrences of a flag at runtime.</span>
|
<span class='doccomment'>/// Checks the number of occurrences of a flag at runtime.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
|
|
|
@ -220,50 +220,50 @@
|
||||||
<span class='doccomment'>//! // ...</span>
|
<span class='doccomment'>//! // ...</span>
|
||||||
<span class='doccomment'>//! </span>
|
<span class='doccomment'>//! </span>
|
||||||
<span class='doccomment'>//! let matches = App::new("MyApp")</span>
|
<span class='doccomment'>//! let matches = App::new("MyApp")</span>
|
||||||
<span class='doccomment'>//! .version("1.0")</span>
|
<span class='doccomment'>//! .version("1.0")</span>
|
||||||
<span class='doccomment'>//! .author("Kevin K. <kbknapp@gmail.com>")</span>
|
<span class='doccomment'>//! .author("Kevin K. <kbknapp@gmail.com>")</span>
|
||||||
<span class='doccomment'>//! .about("Does awesome things")</span>
|
<span class='doccomment'>//! .about("Does awesome things")</span>
|
||||||
<span class='doccomment'>//! .arg(Arg::new("config")</span>
|
<span class='doccomment'>//! .arg(Arg::new("config")</span>
|
||||||
<span class='doccomment'>//! .short("c")</span>
|
<span class='doccomment'>//! .short("c")</span>
|
||||||
<span class='doccomment'>//! .long("config")</span>
|
<span class='doccomment'>//! .long("config")</span>
|
||||||
<span class='doccomment'>//! .help("Sets a custom config file")</span>
|
<span class='doccomment'>//! .help("Sets a custom config file")</span>
|
||||||
<span class='doccomment'>//! .takes_value(true))</span>
|
<span class='doccomment'>//! .takes_value(true))</span>
|
||||||
<span class='doccomment'>//! .arg(Arg::new("output")</span>
|
<span class='doccomment'>//! .arg(Arg::new("output")</span>
|
||||||
<span class='doccomment'>//! .help("Sets an optional output file")</span>
|
<span class='doccomment'>//! .help("Sets an optional output file")</span>
|
||||||
<span class='doccomment'>//! .index(1))</span>
|
<span class='doccomment'>//! .index(1))</span>
|
||||||
<span class='doccomment'>//! .arg(Arg::new("debug")</span>
|
<span class='doccomment'>//! .arg(Arg::new("debug")</span>
|
||||||
<span class='doccomment'>//! .short("d")</span>
|
<span class='doccomment'>//! .short("d")</span>
|
||||||
<span class='doccomment'>//! .multiple(true)</span>
|
<span class='doccomment'>//! .multiple(true)</span>
|
||||||
<span class='doccomment'>//! .help("Turn debugging information on"))</span>
|
<span class='doccomment'>//! .help("Turn debugging information on"))</span>
|
||||||
<span class='doccomment'>//! .subcommand(SubCommand::new("test")</span>
|
<span class='doccomment'>//! .subcommand(SubCommand::new("test")</span>
|
||||||
<span class='doccomment'>//! .about("Has test sub functionality")</span>
|
<span class='doccomment'>//! .about("Has test sub functionality")</span>
|
||||||
<span class='doccomment'>//! .arg(Arg::new("verbose")</span>
|
<span class='doccomment'>//! .arg(Arg::new("verbose")</span>
|
||||||
<span class='doccomment'>//! .short("v")</span>
|
<span class='doccomment'>//! .short("v")</span>
|
||||||
<span class='doccomment'>//! .help("Display verbose information")))</span>
|
<span class='doccomment'>//! .help("Display verbose information")))</span>
|
||||||
<span class='doccomment'>//! .get_matches();</span>
|
<span class='doccomment'>//! .get_matches();</span>
|
||||||
<span class='doccomment'>//!</span>
|
<span class='doccomment'>//!</span>
|
||||||
<span class='doccomment'>//! if let Some(o) = matches.value_of("output") {</span>
|
<span class='doccomment'>//! if let Some(o) = matches.value_of("output") {</span>
|
||||||
<span class='doccomment'>//! println!("Value for output: {}", o);</span>
|
<span class='doccomment'>//! println!("Value for output: {}", o);</span>
|
||||||
<span class='doccomment'>//! }</span>
|
<span class='doccomment'>//! }</span>
|
||||||
<span class='doccomment'>//! </span>
|
<span class='doccomment'>//! </span>
|
||||||
<span class='doccomment'>//! if let Some(c) = matches.value_of("config") {</span>
|
<span class='doccomment'>//! if let Some(c) = matches.value_of("config") {</span>
|
||||||
<span class='doccomment'>//! println!("Value for config: {}", c);</span>
|
<span class='doccomment'>//! println!("Value for config: {}", c);</span>
|
||||||
<span class='doccomment'>//! }</span>
|
<span class='doccomment'>//! }</span>
|
||||||
<span class='doccomment'>//!</span>
|
<span class='doccomment'>//!</span>
|
||||||
<span class='doccomment'>//! match matches.occurrences_of("debug") {</span>
|
<span class='doccomment'>//! match matches.occurrences_of("debug") {</span>
|
||||||
<span class='doccomment'>//! 0 => println!("Debug mode is off"),</span>
|
<span class='doccomment'>//! 0 => println!("Debug mode is off"),</span>
|
||||||
<span class='doccomment'>//! 1 => println!("Debug mode is kind of on"),</span>
|
<span class='doccomment'>//! 1 => println!("Debug mode is kind of on"),</span>
|
||||||
<span class='doccomment'>//! 2 => println!("Debug mode is on"),</span>
|
<span class='doccomment'>//! 2 => println!("Debug mode is on"),</span>
|
||||||
<span class='doccomment'>//! 3 | _ => println!("Don't be crazy"),</span>
|
<span class='doccomment'>//! 3 | _ => println!("Don't be crazy"),</span>
|
||||||
<span class='doccomment'>//! }</span>
|
<span class='doccomment'>//! }</span>
|
||||||
<span class='doccomment'>//! </span>
|
<span class='doccomment'>//! </span>
|
||||||
<span class='doccomment'>//! if let Some(ref matches) = matches.subcommand_matches("test") {</span>
|
<span class='doccomment'>//! if let Some(ref matches) = matches.subcommand_matches("test") {</span>
|
||||||
<span class='doccomment'>//! if matches.is_present("verbose") {</span>
|
<span class='doccomment'>//! if matches.is_present("verbose") {</span>
|
||||||
<span class='doccomment'>//! println!("Printing verbose test info...");</span>
|
<span class='doccomment'>//! println!("Printing verbose test info...");</span>
|
||||||
<span class='doccomment'>//! } else {</span>
|
<span class='doccomment'>//! } else {</span>
|
||||||
<span class='doccomment'>//! println!("Not printing regular test info...");</span>
|
<span class='doccomment'>//! println!("Not printing regular test info...");</span>
|
||||||
<span class='doccomment'>//! }</span>
|
<span class='doccomment'>//! }</span>
|
||||||
<span class='doccomment'>//! }</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'>//! // more porgram logic goes here...</span>
|
||||||
<span class='doccomment'>//! ```</span>
|
<span class='doccomment'>//! ```</span>
|
||||||
|
@ -277,22 +277,22 @@
|
||||||
<span class='doccomment'>//! Does awesome things</span>
|
<span class='doccomment'>//! Does awesome things</span>
|
||||||
<span class='doccomment'>//! </span>
|
<span class='doccomment'>//! </span>
|
||||||
<span class='doccomment'>//! USAGE:</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'>//! </span>
|
||||||
<span class='doccomment'>//! FLAGS:</span>
|
<span class='doccomment'>//! FLAGS:</span>
|
||||||
<span class='doccomment'>//! -d Turn debugging information on</span>
|
<span class='doccomment'>//! -d Turn debugging information on</span>
|
||||||
<span class='doccomment'>//! -h,--help Prints this message</span>
|
<span class='doccomment'>//! -h,--help Prints this message</span>
|
||||||
<span class='doccomment'>//! -v,--version Prints version information</span>
|
<span class='doccomment'>//! -v,--version Prints version information</span>
|
||||||
<span class='doccomment'>//! </span>
|
<span class='doccomment'>//! </span>
|
||||||
<span class='doccomment'>//! OPTIONS:</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'>//!</span>
|
||||||
<span class='doccomment'>//! POSITIONAL ARGUMENTS:</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'>//!</span>
|
||||||
<span class='doccomment'>//! SUBCOMMANDS:</span>
|
<span class='doccomment'>//! SUBCOMMANDS:</span>
|
||||||
<span class='doccomment'>//! help Prints this message</span>
|
<span class='doccomment'>//! help Prints this message</span>
|
||||||
<span class='doccomment'>//! test Has test sub-functionality</span>
|
<span class='doccomment'>//! test Has test sub-functionality</span>
|
||||||
<span class='doccomment'>//! ```</span>
|
<span class='doccomment'>//! ```</span>
|
||||||
|
|
||||||
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>argmatches</span>::<span class='ident'>ArgMatches</span>;
|
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>argmatches</span>::<span class='ident'>ArgMatches</span>;
|
||||||
|
@ -310,46 +310,46 @@
|
||||||
<span class='kw'>mod</span> <span class='ident'>tests</span> {
|
<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='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'>test</span>]</span>
|
||||||
<span class='attribute'>#[<span class='ident'>should_panic</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='kw'>fn</span> <span class='ident'>unique_arg_names</span>(){
|
||||||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"some"</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
|
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"some"</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'>"arg"</span>).<span class='ident'>short</span>(<span class='string'>"a"</span>),
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg"</span>).<span class='ident'>short</span>(<span class='string'>"a"</span>),
|
||||||
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg"</span>).<span class='ident'>short</span>(<span class='string'>"b"</span>)
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg"</span>).<span class='ident'>short</span>(<span class='string'>"b"</span>)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
||||||
<span class='attribute'>#[<span class='ident'>should_panic</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='kw'>fn</span> <span class='ident'>unique_arg_shorts</span>(){
|
||||||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"some"</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
|
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"some"</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'>"arg1"</span>).<span class='ident'>short</span>(<span class='string'>"a"</span>),
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg1"</span>).<span class='ident'>short</span>(<span class='string'>"a"</span>),
|
||||||
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg2"</span>).<span class='ident'>short</span>(<span class='string'>"a"</span>)
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg2"</span>).<span class='ident'>short</span>(<span class='string'>"a"</span>)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
||||||
<span class='attribute'>#[<span class='ident'>should_panic</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='kw'>fn</span> <span class='ident'>unique_arg_longs</span>(){
|
||||||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"some"</span>).<span class='ident'>args</span>(<span class='macro'>vec</span><span class='macro'>!</span>[
|
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"some"</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'>"arg1"</span>).<span class='ident'>long</span>(<span class='string'>"long"</span>),
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg1"</span>).<span class='ident'>long</span>(<span class='string'>"long"</span>),
|
||||||
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg2"</span>).<span class='ident'>long</span>(<span class='string'>"long"</span>)
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"arg2"</span>).<span class='ident'>long</span>(<span class='string'>"long"</span>)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
||||||
<span class='kw'>fn</span> <span class='ident'>create_app</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'>"some"</span>).<span class='ident'>about</span>(<span class='string'>"about"</span>).<span class='ident'>author</span>(<span class='string'>"author"</span>).<span class='ident'>version</span>(<span class='string'>"1.0"</span>);
|
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"some"</span>).<span class='ident'>about</span>(<span class='string'>"about"</span>).<span class='ident'>author</span>(<span class='string'>"author"</span>).<span class='ident'>version</span>(<span class='string'>"1.0"</span>);
|
||||||
}
|
}
|
||||||
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
||||||
<span class='kw'>fn</span> <span class='ident'>create_arg_flag</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'>"some"</span>).<span class='ident'>short</span>(<span class='string'>"a"</span>).<span class='ident'>long</span>(<span class='string'>"long"</span>).<span class='ident'>help</span>(<span class='string'>"help with some arg"</span>).<span class='ident'>multiple</span>(<span class='boolval'>true</span>);
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"some"</span>).<span class='ident'>short</span>(<span class='string'>"a"</span>).<span class='ident'>long</span>(<span class='string'>"long"</span>).<span class='ident'>help</span>(<span class='string'>"help with some arg"</span>).<span class='ident'>multiple</span>(<span class='boolval'>true</span>);
|
||||||
}
|
}
|
||||||
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
<span class='attribute'>#[<span class='ident'>test</span>]</span>
|
||||||
<span class='kw'>fn</span> <span class='ident'>create_arg_pos</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'>"some"</span>).<span class='ident'>index</span>(<span class='number'>1</span>).<span class='ident'>help</span>(<span class='string'>"help with some arg"</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"some"</span>).<span class='ident'>index</span>(<span class='number'>1</span>).<span class='ident'>help</span>(<span class='string'>"help with some arg"</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'>test</span>]</span>
|
||||||
<span class='kw'>fn</span> <span class='ident'>create_arg_opt</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'>"some"</span>).<span class='ident'>short</span>(<span class='string'>"s"</span>).<span class='ident'>long</span>(<span class='string'>"some"</span>).<span class='ident'>takes_value</span>(<span class='boolval'>true</span>).<span class='ident'>help</span>(<span class='string'>"help with some arg"</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
|
<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"some"</span>).<span class='ident'>short</span>(<span class='string'>"s"</span>).<span class='ident'>long</span>(<span class='string'>"some"</span>).<span class='ident'>takes_value</span>(<span class='boolval'>true</span>).<span class='ident'>help</span>(<span class='string'>"help with some arg"</span>).<span class='ident'>required</span>(<span class='boolval'>true</span>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -101,31 +101,31 @@
|
||||||
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
<span class='doccomment'>/// # let matches = App::new("myprog")</span>
|
||||||
<span class='doccomment'>/// # .subcommand(</span>
|
<span class='doccomment'>/// # .subcommand(</span>
|
||||||
<span class='doccomment'>/// SubCommand::new("conifg")</span>
|
<span class='doccomment'>/// SubCommand::new("conifg")</span>
|
||||||
<span class='doccomment'>/// .about("Used for configuration")</span>
|
<span class='doccomment'>/// .about("Used for configuration")</span>
|
||||||
<span class='doccomment'>/// .arg(Arg::new("config_file")</span>
|
<span class='doccomment'>/// .arg(Arg::new("config_file")</span>
|
||||||
<span class='doccomment'>/// .help("The configuration file to use")</span>
|
<span class='doccomment'>/// .help("The configuration file to use")</span>
|
||||||
<span class='doccomment'>/// .index(1))</span>
|
<span class='doccomment'>/// .index(1))</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</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='kw'>struct</span> <span class='ident'>SubCommand</span> {
|
||||||
<span class='kw'>pub</span> <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>,
|
<span class='kw'>pub</span> <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='lifetime'>'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'>matches</span>: <span class='ident'>ArgMatches</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class='kw'>impl</span> <span class='ident'>SubCommand</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'>/// 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'>/// to the user when they print version or help and usage information.</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// # Example</span>
|
<span class='doccomment'>/// # Example</span>
|
||||||
<span class='doccomment'>///</span>
|
<span class='doccomment'>///</span>
|
||||||
<span class='doccomment'>/// ```no_run</span>
|
<span class='doccomment'>/// ```no_run</span>
|
||||||
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</span>
|
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</span>
|
||||||
<span class='doccomment'>/// # let prog = App::new("myprog").subcommand(</span>
|
<span class='doccomment'>/// # let prog = App::new("myprog").subcommand(</span>
|
||||||
<span class='doccomment'>/// SubCommand::new("config")</span>
|
<span class='doccomment'>/// SubCommand::new("config")</span>
|
||||||
<span class='doccomment'>/// # ).get_matches();</span>
|
<span class='doccomment'>/// # ).get_matches();</span>
|
||||||
<span class='doccomment'>/// ```</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>App</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'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>App</span> {
|
||||||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='ident'>name</span>)
|
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='ident'>name</span>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue