mirror of
https://github.com/clap-rs/clap
synced 2024-12-12 22:02:35 +00:00
Rebuilt docs
This commit is contained in:
parent
152aa8919a
commit
43ddb14972
5 changed files with 68 additions and 71 deletions
|
@ -57,7 +57,7 @@
|
|||
|
||||
<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='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>
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
|||
.<span class='ident'>short</span>(<span class='string'>"d"</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'>subcomamnd</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'>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>)
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<section id='main' class="content struct">
|
||||
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>clap</a>::<wbr><a class='struct' href=''>ArgMatches</a><wbr></span><span class='out-of-band'><span id='render-detail'>
|
||||
<a id="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a>
|
||||
</span><a id='src-4545' href='../src/clap/argmatches.rs.html#61-67'>[src]</a></span></h1>
|
||||
</span><a id='src-4545' href='../src/clap/argmatches.rs.html#60-66'>[src]</a></span></h1>
|
||||
<pre class='rust struct'>pub struct ArgMatches {
|
||||
pub matches_of: &'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>,
|
||||
pub flags: <a class='struct' href='http://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html' title='std::collections::hash::map::HashMap'>HashMap</a><&'static <a href='http://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, FlagArg>,
|
||||
|
@ -58,41 +58,40 @@ the methods in order to query information.</p>
|
|||
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
<span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"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='comment'>// adding of arguments and configuration goes here...</span>
|
||||
.<span class='ident'>get_matches</span>();
|
||||
<span class='comment'>// if you had an argument named "output" that takes a value </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='comment'>// if you had an argument named "output" that takes a value </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='comment'>// Although not advised, if you have a required argument</span>
|
||||
<span class='comment'>// you can call .unwrap() because the program will exit long before</span>
|
||||
<span class='comment'>// here at noticing the user didn't supply a required argument...</span>
|
||||
<span class='comment'>// use at your own risk ;)</span>
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Config file: {}"</span>, <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>"config"</span>).<span class='ident'>unwrap</span>());
|
||||
<span class='comment'>// Although not advised, if you have a required argument</span>
|
||||
<span class='comment'>// you can call .unwrap() because the program will exit long before</span>
|
||||
<span class='comment'>// here at noticing the user didn't supply a required argument...</span>
|
||||
<span class='comment'>// use at your own risk ;)</span>
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Config file: {}"</span>, <span class='ident'>matches</span>.<span class='ident'>value_of</span>(<span class='string'>"config"</span>).<span class='ident'>unwrap</span>());
|
||||
|
||||
<span class='comment'>// You can check the present of an argument</span>
|
||||
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>is_present</span>(<span class='string'>"debug"</span>) {
|
||||
<span class='comment'>// Checking if "debug" was present was necessary,</span>
|
||||
<span class='comment'>// as occurrences returns 0 if a flag isn't found</span>
|
||||
<span class='comment'>// but we can check how many times "debug" was found</span>
|
||||
<span class='comment'>// if we allow multiple (if multiple isn't allowed it always be 1 or 0)</span>
|
||||
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>"debug"</span>) <span class='op'>></span> <span class='number'>1</span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode is REALLY on"</span>);
|
||||
} <span class='kw'>else</span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode kind of on"</span>);
|
||||
}
|
||||
}
|
||||
<span class='comment'>// You can check the present of an argument</span>
|
||||
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>is_present</span>(<span class='string'>"debug"</span>) {
|
||||
<span class='comment'>// Checking if "debug" was present was necessary,</span>
|
||||
<span class='comment'>// as occurrences returns 0 if a flag isn't found</span>
|
||||
<span class='comment'>// but we can check how many times "debug" was found</span>
|
||||
<span class='comment'>// if we allow multiple (if multiple isn't allowed it always be 1 or 0)</span>
|
||||
<span class='kw'>if</span> <span class='ident'>matches</span>.<span class='ident'>occurrences_of</span>(<span class='string'>"debug"</span>) <span class='op'>></span> <span class='number'>1</span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode is REALLY on"</span>);
|
||||
} <span class='kw'>else</span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Debug mode kind of on"</span>);
|
||||
}
|
||||
}
|
||||
|
||||
<span class='comment'>// You can get the sub-matches of a particular subcommand (in this case "test")</span>
|
||||
<span class='comment'>// If "test" had it's own "-l" flag you could check for it's presence accordingly</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'>"list"</span>) {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Printing testing lists..."</span>);
|
||||
} <span class='kw'>else</span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Not printing testing lists..."</span>);
|
||||
}
|
||||
<span class='comment'>// You can get the sub-matches of a particular subcommand (in this case "test")</span>
|
||||
<span class='comment'>// If "test" had it's own "-l" flag you could check for it's presence accordingly</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'>"list"</span>) {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Printing testing lists..."</span>);
|
||||
} <span class='kw'>else</span> {
|
||||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Not printing testing lists..."</span>);
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
@ -157,7 +156,7 @@ at all.</p>
|
|||
|
||||
<h1 id="example" class='section-header'><a
|
||||
href="#example">Example</a></h1><pre id='rust-example-rendered' class='rust '>
|
||||
<span class='kw'>match</span> <span class='ident'>app_matches</span>.<span class='ident'>subcommand_</span>() {
|
||||
<span class='kw'>match</span> <span class='ident'>app_matches</span>.<span class='ident'>subcommand_name</span>() {
|
||||
<span class='prelude-val'>Some</span>(<span class='string'>"test"</span>) <span class='op'>=></span> {}, <span class='comment'>// test was used</span>
|
||||
<span class='prelude-val'>Some</span>(<span class='string'>"config"</span>) <span class='op'>=></span> {}, <span class='comment'>// config was used</span>
|
||||
_ <span class='op'>=></span> {}, <span class='comment'>// Either no subcommand or one not tested for...</span>
|
||||
|
|
|
@ -247,7 +247,6 @@
|
|||
<span id="205">205</span>
|
||||
<span id="206">206</span>
|
||||
<span id="207">207</span>
|
||||
<span id="208">208</span>
|
||||
</pre><pre class='rust '>
|
||||
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
|
||||
|
||||
|
@ -265,7 +264,7 @@
|
|||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// ```no_run</span>
|
||||
<span class='doccomment'>/// # use clap::{App, Arg};</span>
|
||||
<span class='doccomment'>/// let matches = App::new("MyApp")</span>
|
||||
<span class='doccomment'>/// let matches = App::new("MyApp")</span>
|
||||
<span class='doccomment'>/// // adding of arguments and configuration goes here...</span>
|
||||
<span class='doccomment'>/// # .arg(Arg::new("config")</span>
|
||||
<span class='doccomment'>/// # .long("config")</span>
|
||||
|
@ -275,38 +274,37 @@
|
|||
<span class='doccomment'>/// # .short("d")</span>
|
||||
<span class='doccomment'>/// # .multiple(true))</span>
|
||||
<span class='doccomment'>/// .get_matches();</span>
|
||||
<span class='doccomment'>/// // if you had an argument named "output" that takes a value </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'>/// }</span>
|
||||
<span class='doccomment'>/// // if you had an argument named "output" that takes a value </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'>/// }</span>
|
||||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// // Although not advised, if you have a required argument</span>
|
||||
<span class='doccomment'>/// // you can call .unwrap() because the program will exit long before</span>
|
||||
<span class='doccomment'>/// // here at noticing the user didn't supply a required argument...</span>
|
||||
<span class='doccomment'>/// // use at your own risk ;)</span>
|
||||
<span class='doccomment'>/// println!("Config file: {}", matches.value_of("config").unwrap());</span>
|
||||
<span class='doccomment'>/// // Although not advised, if you have a required argument</span>
|
||||
<span class='doccomment'>/// // you can call .unwrap() because the program will exit long before</span>
|
||||
<span class='doccomment'>/// // here at noticing the user didn't supply a required argument...</span>
|
||||
<span class='doccomment'>/// // use at your own risk ;)</span>
|
||||
<span class='doccomment'>/// println!("Config file: {}", matches.value_of("config").unwrap());</span>
|
||||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// // You can check the present of an argument</span>
|
||||
<span class='doccomment'>/// if matches.is_present("debug") {</span>
|
||||
<span class='doccomment'>/// // Checking if "debug" was present was necessary,</span>
|
||||
<span class='doccomment'>/// // as occurrences returns 0 if a flag isn't found</span>
|
||||
<span class='doccomment'>/// // but we can check how many times "debug" was found</span>
|
||||
<span class='doccomment'>/// // if we allow multiple (if multiple isn't allowed it always be 1 or 0)</span>
|
||||
<span class='doccomment'>/// if matches.occurrences_of("debug") > 1 {</span>
|
||||
<span class='doccomment'>/// println!("Debug mode is REALLY on");</span>
|
||||
<span class='doccomment'>/// } else {</span>
|
||||
<span class='doccomment'>/// println!("Debug mode kind of on");</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>/// // You can check the present of an argument</span>
|
||||
<span class='doccomment'>/// if matches.is_present("debug") {</span>
|
||||
<span class='doccomment'>/// // Checking if "debug" was present was necessary,</span>
|
||||
<span class='doccomment'>/// // as occurrences returns 0 if a flag isn't found</span>
|
||||
<span class='doccomment'>/// // but we can check how many times "debug" was found</span>
|
||||
<span class='doccomment'>/// // if we allow multiple (if multiple isn't allowed it always be 1 or 0)</span>
|
||||
<span class='doccomment'>/// if matches.occurrences_of("debug") > 1 {</span>
|
||||
<span class='doccomment'>/// println!("Debug mode is REALLY on");</span>
|
||||
<span class='doccomment'>/// } else {</span>
|
||||
<span class='doccomment'>/// println!("Debug mode kind of on");</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// // You can get the sub-matches of a particular subcommand (in this case "test")</span>
|
||||
<span class='doccomment'>/// // If "test" had it's own "-l" flag you could check for it's presence accordingly</span>
|
||||
<span class='doccomment'>/// if let Some(ref matches) = matches.subcommand_matches("test") {</span>
|
||||
<span class='doccomment'>/// if matches.is_present("list") {</span>
|
||||
<span class='doccomment'>/// println!("Printing testing lists...");</span>
|
||||
<span class='doccomment'>/// } else {</span>
|
||||
<span class='doccomment'>/// println!("Not printing testing lists...");</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>/// // You can get the sub-matches of a particular subcommand (in this case "test")</span>
|
||||
<span class='doccomment'>/// // If "test" had it's own "-l" flag you could check for it's presence accordingly</span>
|
||||
<span class='doccomment'>/// if let Some(ref matches) = matches.subcommand_matches("test") {</span>
|
||||
<span class='doccomment'>/// if matches.is_present("list") {</span>
|
||||
<span class='doccomment'>/// println!("Printing testing lists...");</span>
|
||||
<span class='doccomment'>/// } else {</span>
|
||||
<span class='doccomment'>/// println!("Not printing testing lists...");</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ArgMatches</span> {
|
||||
|
@ -423,7 +421,7 @@
|
|||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// ```no_run</span>
|
||||
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</span>
|
||||
<span class='doccomment'>/// # let matches = App::new("myapp").subcommand(SubCommand::new("test")).get_matches();</span>
|
||||
<span class='doccomment'>/// # let app_matches = App::new("myapp").subcommand(SubCommand::new("test")).get_matches();</span>
|
||||
<span class='doccomment'>/// if let Some(matches) = app_matches.subcommand_matches("test") {</span>
|
||||
<span class='doccomment'>/// // Use matches as normal</span>
|
||||
<span class='doccomment'>/// }</span>
|
||||
|
@ -443,8 +441,8 @@
|
|||
<span class='doccomment'>///</span>
|
||||
<span class='doccomment'>/// ```no_run</span>
|
||||
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</span>
|
||||
<span class='doccomment'>/// # let matches = App::new("myapp").subcommand(SubCommand::new("test")).get_matches();</span>
|
||||
<span class='doccomment'>/// match app_matches.subcommand_() {</span>
|
||||
<span class='doccomment'>/// # let app_matches = App::new("myapp").subcommand(SubCommand::new("test")).get_matches();</span>
|
||||
<span class='doccomment'>/// match app_matches.subcommand_name() {</span>
|
||||
<span class='doccomment'>/// Some("test") => {}, // test was used</span>
|
||||
<span class='doccomment'>/// Some("config") => {}, // config was used</span>
|
||||
<span class='doccomment'>/// _ => {}, // Either no subcommand or one not tested for...</span>
|
||||
|
|
|
@ -215,7 +215,7 @@
|
|||
<span class='doccomment'>//! Example:</span>
|
||||
<span class='doccomment'>//! </span>
|
||||
<span class='doccomment'>//! ```no_run</span>
|
||||
<span class='doccomment'>//! use clap::{Arg, App};</span>
|
||||
<span class='doccomment'>//! use clap::{Arg, App, SubCommand};</span>
|
||||
<span class='doccomment'>//!</span>
|
||||
<span class='doccomment'>//! // ...</span>
|
||||
<span class='doccomment'>//! </span>
|
||||
|
@ -235,7 +235,7 @@
|
|||
<span class='doccomment'>//! .short("d")</span>
|
||||
<span class='doccomment'>//! .multiple(true)</span>
|
||||
<span class='doccomment'>//! .help("Turn debugging information on"))</span>
|
||||
<span class='doccomment'>//! .subcomamnd(SubCommand::new("test")</span>
|
||||
<span class='doccomment'>//! .subcommand(SubCommand::new("test")</span>
|
||||
<span class='doccomment'>//! .about("Has test sub functionality")</span>
|
||||
<span class='doccomment'>//! .arg(Arg::new("verbose")</span>
|
||||
<span class='doccomment'>//! .short("v")</span>
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
<span class='doccomment'>/// ```no_run</span>
|
||||
<span class='doccomment'>/// # use clap::{App, Arg, SubCommand};</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'>/// .about("Used for configuration")</span>
|
||||
<span class='doccomment'>/// .arg(Arg::new("config_file")</span>
|
||||
|
|
Loading…
Reference in a new issue