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
|
@ -45,23 +45,23 @@
|
|||
<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>
|
||||
<div class='docblock'><p>A simply library for parsing command line arguments when writing
|
||||
command line and console applications.</p>
|
||||
command line and console applications.</p>
|
||||
|
||||
<p>You can use <code>clap</code> to lay out a list of possible valid command line arguments and let <code>clap</code> parse the string given by the user at runtime.
|
||||
When using <code>clap</code> you define a set of parameters and rules for your arguments and at runtime <code>clap</code> will determine their validity.
|
||||
Also, <code>clap</code> provides the traditional version and help switches '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>
|
||||
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.
|
||||
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
|
||||
determine the functioning of your program.</p>
|
||||
determine the functioning of your program.</p>
|
||||
|
||||
<p># Example</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
<span class='kw'>use</span> <span class='ident'>clap</span>::{<span class='ident'>Arg</span>, <span class='ident'>App</span>, <span class='ident'>SubCommand</span>};
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
<span class='kw'>use</span> <span class='ident'>clap</span>::{<span class='ident'>Arg</span>, <span class='ident'>App</span>, <span class='ident'>SubCommand</span>};
|
||||
|
||||
<span class='comment'>// ...</span>
|
||||
<span class='comment'>// ...</span>
|
||||
|
||||
<span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"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'>author</span>(<span class='string'>"Kevin K. <kbknapp@gmail.com>"</span>)
|
||||
.<span class='ident'>about</span>(<span class='string'>"Does awesome things"</span>)
|
||||
|
@ -92,14 +92,14 @@
|
|||
<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'>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'>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='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Printing verbose test info..."</span>);
|
||||
} <span class='kw'>else</span> {
|
||||
|
@ -107,31 +107,31 @@
|
|||
}
|
||||
}
|
||||
|
||||
<span class='comment'>// more porgram logic goes here...</span>
|
||||
<span class='comment'>// more porgram logic goes here...</span>
|
||||
</pre>
|
||||
|
||||
<p>If you were to compile the above program and run it with the flag <code>--help</code> or <code>-h</code> the following output woud be presented</p>
|
||||
|
||||
<pre><code class="language-sh"> $ myprog --help
|
||||
MyApp 1.0
|
||||
Kevin K. <kbknapp@gmail.com>
|
||||
Does awesome things
|
||||
<pre><code class="language-sh">$ myprog --help
|
||||
MyApp 1.0
|
||||
Kevin K. <kbknapp@gmail.com>
|
||||
Does awesome things
|
||||
|
||||
USAGE:
|
||||
USAGE:
|
||||
MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]
|
||||
|
||||
FLAGS:
|
||||
FLAGS:
|
||||
-d Turn debugging information on
|
||||
-h,--help Prints this message
|
||||
-v,--version Prints version information
|
||||
|
||||
OPTIONS:
|
||||
OPTIONS:
|
||||
-c,--config <config> Sets a custom config file
|
||||
|
||||
POSITIONAL ARGUMENTS:
|
||||
POSITIONAL ARGUMENTS:
|
||||
output Sets an optional output file
|
||||
|
||||
SUBCOMMANDS:
|
||||
SUBCOMMANDS:
|
||||
help Prints this message
|
||||
test Has test sub-functionality
|
||||
</code></pre>
|
||||
|
@ -141,7 +141,7 @@
|
|||
<td><a class='stability Unmarked' title='No stability level'></a><a class='struct' href='struct.App.html'
|
||||
title='clap::App'>App</a></td>
|
||||
<td class='docblock short'><p>Used to create a representation of the program and all possible command line arguments
|
||||
for parsing at runtime.</p>
|
||||
for parsing at runtime.</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -51,14 +51,14 @@
|
|||
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
|
||||
}</pre><div class='docblock'><p>Used to create a representation of the program and all possible command line arguments
|
||||
for parsing at runtime.</p>
|
||||
for parsing at runtime.</p>
|
||||
|
||||
<p>Stores a list of all posisble arguments, as well as information displayed to the user such as
|
||||
help and versioning information.</p>
|
||||
help and versioning information.</p>
|
||||
|
||||
<p># Example</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
<span class='kw'>let</span> <span class='ident'>myprog</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
<span class='kw'>let</span> <span class='ident'>myprog</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</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'>about</span>(<span class='string'>"Explains in brief what the program does"</span>)
|
||||
|
@ -68,7 +68,7 @@
|
|||
)
|
||||
.<span class='ident'>get_matches</span>();
|
||||
|
||||
<span class='comment'>// Your pogram logic starts here...</span>
|
||||
<span class='comment'>// Your pogram logic starts here...</span>
|
||||
</pre>
|
||||
</div><h2 class='fields'>Fields</h2>
|
||||
<table><tr><td id='structfield.name'><a class='stability Unmarked' title='No stability level'></a><code>name</code></td><td><div class='docblock'><p>The name displayed to the user when showing version and help/usage information</p>
|
||||
|
@ -119,43 +119,43 @@ 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 class='docblock'><p>Adds an argument to the list of valid possibilties</p>
|
||||
|
||||
<p># Example</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>)
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>)
|
||||
.<span class='ident'>short</span>(<span class='string'>"c"</span>)
|
||||
<span class='comment'>// Additional argument configuration goes here...</span>
|
||||
)
|
||||
)
|
||||
</pre>
|
||||
</div><h4 id='method.args' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.args' class='fnname'>args</a>(self, args: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><<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>
|
||||
|
||||
<p># Example</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>args</span>( <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>).<span class='ident'>short</span>(<span class='string'>"c"</span>),
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>args</span>( <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Arg</span>::<span class='ident'>new</span>(<span class='string'>"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>)])
|
||||
</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 class='docblock'><p>Adds a subcommand to the list of valid possibilties. Subcommands
|
||||
are effectively sub apps, because they can contain their own arguments
|
||||
and subcommands. They also function just like apps, in that they get their
|
||||
own auto generated help and version switches.</p>
|
||||
are effectively sub apps, because they can contain their own arguments
|
||||
and subcommands. They also function just like apps, in that they get their
|
||||
own auto generated help and version switches.</p>
|
||||
|
||||
<p># Example</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"config"</span>)
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"config"</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'>index</span>(<span class='number'>1</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>
|
||||
)
|
||||
)
|
||||
</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 class='docblock'><p>Adds multiple subcommands to the list of valid possibilties</p>
|
||||
|
||||
<p># Example</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>subcommands</span>( <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>subcommands</span>( <span class='macro'>vec</span><span class='macro'>!</span>[
|
||||
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"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'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"debug"</span>).<span class='ident'>about</span>(<span class='string'>"Controls debug functionality"</span>)])
|
||||
|
|
|
@ -170,15 +170,15 @@ arguments, they do not need to be set for each.</p>
|
|||
</pre>
|
||||
</div><h4 id='method.mutually_excludes_all' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.mutually_excludes_all' class='fnname'>mutually_excludes_all</a>(self, names: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><&'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,
|
||||
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
|
||||
by default. Mutually exclusive rules only need to be set for one of the two
|
||||
arguments, they do not need to be set for each.</p>
|
||||
by default. Mutually exclusive rules only need to be set for one of the two
|
||||
arguments, they do not need to be set for each.</p>
|
||||
|
||||
<p>Example:</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>mutually_excludes_all</span>(
|
||||
.<span class='ident'>mutually_excludes_all</span>(
|
||||
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"debug"</span>, <span class='string'>"input"</span>])
|
||||
</pre>
|
||||
</div><h4 id='method.requires' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.requires' class='fnname'>requires</a>(self, name: &'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>
|
||||
|
@ -193,14 +193,14 @@ using this argument, the following argument <em>must</em> be present.</p>
|
|||
</pre>
|
||||
</div><h4 id='method.requires_all' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.requires_all' class='fnname'>requires_all</a>(self, names: <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><&'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
|
||||
using this argument, the following arguments <em>must</em> be present.</p>
|
||||
using this argument, the following arguments <em>must</em> be present.</p>
|
||||
|
||||
<p><strong>NOTE:</strong> Mutually exclusive rules take precedence over being required
|
||||
by default. </p>
|
||||
by default. </p>
|
||||
|
||||
<p>Example:</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
.<span class='ident'>requires_all</span>(
|
||||
.<span class='ident'>requires_all</span>(
|
||||
<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"debug"</span>, <span class='string'>"input"</span>])
|
||||
</pre>
|
||||
</div><h4 id='method.takes_value' class='method'><a class='stability Unmarked' title='No stability level'></a><code>fn <a href='#method.takes_value' class='fnname'>takes_value</a>(self, tv: <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -> <a class='struct' href='../clap/struct.Arg.html' title='clap::Arg'>Arg</a></code></h4>
|
||||
|
|
|
@ -50,12 +50,12 @@
|
|||
}</pre><div class='docblock'><p>The abstract representation of a command line subcommand used by the consumer of the library.</p>
|
||||
|
||||
<p>This struct is used by the library consumer and describes all the valid options of the subcommand for
|
||||
their program. SubCommands are treated like "sub apps" and contain all the same possibilities (such as
|
||||
their own arguments and subcommands).</p>
|
||||
their program. SubCommands are treated like "sub apps" and contain all the same possibilities (such as
|
||||
their own arguments and subcommands).</p>
|
||||
|
||||
<p># Example</p>
|
||||
<pre id='rust-example-rendered' class='rust '>
|
||||
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"conifg"</span>)
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
<span class='ident'>SubCommand</span>::<span class='ident'>new</span>(<span class='string'>"conifg"</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'>help</span>(<span class='string'>"The configuration file to use"</span>)
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue