| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Used to create a representation of a command line program and all possible command line arguments. Application settings are set using the “builder pattern” with the `App::get_matches` family of methods being the terminal methods that starts the runtime-parsing process. These methods then return information about the user supplied arguments (or lack there of)."><meta name="keywords" content="rust, rustlang, rust-lang, App"><title>App in clap - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../clap/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../clap/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">App</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.about">about</a></li><li><a href="#method.after_help">after_help</a></li><li><a href="#method.alias">alias</a></li><li><a href="#method.aliases">aliases</a></li><li><a href="#method.arg">arg</a></li><li><a href="#method.arg_from_usage">arg_from_usage</a></li><li><a href="#method.args">args</a></li><li><a href="#method.args_from_usage">args_from_usage</a></li><li><a href="#method.author">author</a></li><li><a href="#method.before_help">before_help</a></li><li><a href="#method.bin_name">bin_name</a></li><li><a href="#method.display_order">display_order</a></li><li><a href="#method.gen_completions">gen_completions</a></li><li><a href="#method.gen_completions_to">gen_completions_to</a></li><li><a href="#method.get_bin_name">get_bin_name</a></li><li><a href="#method.get_matches">get_matches</a></li><li><a href="#method.get_matches_from">get_matches_from</a></li><li><a href="#method.get_matches_from_safe">get_matches_from_safe</a></li><li><a href="#method.get_matches_from_safe_borrow">get_matches_from_safe_borrow</a></li><li><a href="#method.get_matches_safe">get_matches_safe</a></li><li><a href="#method.get_name">get_name</a></li><li><a href="#method.global_setting">global_setting</a></li><li><a href="#method.global_settings">global_settings</a></li><li><a href="#method.group">group</a></li><li><a href="#method.groups">groups</a></li><li><a href="#method.help">help</a></li><li><a href="#method.help_message">help_message</a></li><li><a href="#method.help_short">help_short</a></li><li><a href="#method.long_about">long_about</a></li><li><a href="#method.long_version">long_version</a></li><li><a href="#method.max_term_width">max_term_width</a></li><li><a href="#method.name">name</a></li><li><a href="#method.new">new</a></li><li><a href="#method.print_help">print_help</a></li><li><a href="#method.print_long_help">print_long_help</a></li><li><a href="#method.set_term_width">set_term_width</a></li><li><a href="#method.setting">setting</a></li><li><a href="#method.settings">settings</a></li><li><a href="#method.subcommand">subcommand</a></li><li><a href="#method.subcommands">subcommands</a></li><li><a href="#method.template">template</a></li><li><a href="#method.unset_setting">unset_setting</a></li><li><a href="#method.unset_settings">unset_settings</a></li><li><a href="#method.usage">usage</a></li><li><a href="#method.version">version</a></li><li><a href="#method.version_message">version_message</a></li><li><a href="#method.version_short">version_short</a></li><li><a href="#method.visible_alias">visible_alias</a></li><li><a href="#method.visible_aliases">visible_aliases</a></li><li><a href="#method.with_defaults">with_defaults</a></li><li><a href="#method.write_help">write_help</a></li><li><a href="#method.write_long_help">write_long_help</a></li><li><a href="#method.write_long_version">write_long_version</a></li><li><a href="#method.write_version">write_version</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Clone-for-App%3C%27a%2C%20%27b%3E">Clone</a></li><li><a href="#impl-Display-for-App%3C%27n%2C%20%27e%3E">Display</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-App%3C%27a%2C%20%27b%3E">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-App%3C%27a%2C%20%27b%3E">!Send</a></li><li><a href="#impl-Sync-for-App%3C%27a%2C%20%27b%3E">!Sync</a></li><li><a href="#impl-Unpin-for-App%3C%27a%2C%20%27b%3E">Unpin</a></li><li><a href="#impl-UnwindSafe-for-App%3C%27a%2C%20%27b%3E">!UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-App%3C%27a%2C%20%27b%3E">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-App%3C%27a%2C%20%27b%3E">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-App%3C%27a%2C%20%27b%3E">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-App%3C%27a%2C%20%27b%3E">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-App%3C%27a%2C%20%27b%3E">Into<U></a></li><li><a href="#impl-ToOwned-for-App%3C%27a%2C%20%27b%3E">ToOwned</a></li><li><a href="#impl-ToString-for-App%3C%27a%2C%20%27b%3E">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-App%3C%27a%2C%20%27b%3E">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-App%3C%27a%2C%20%27b%3E">TryInto<U></a></li></ul></section><h2><a href="index.html">In clap</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">clap</a>::<wbr><a class="struct" href="#">App</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/clap/app/mod.rs.html#63-69">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct App<'a, 'b><span class="where fmt-newline">where<br> 'a: 'b,</span>{ /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Used to create a representation of a command line program and all possible command line |
| arguments. Application settings are set using the “builder pattern” with the |
| <a href="./struct.App.html#method.get_matches"><code>App::get_matches</code></a> family of methods being the terminal methods that starts the |
| runtime-parsing process. These methods then return information about the user supplied |
| arguments (or lack there of).</p> |
| <p><strong>NOTE:</strong> There aren’t any mandatory “options” that one must set. The “options” may |
| also appear in any order (so long as one of the <a href="./struct.App.html#method.get_matches"><code>App::get_matches</code></a> methods is the last method |
| called).</p> |
| <h2 id="examples"><a href="#examples">Examples</a></h2> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>m = App::new(<span class="string">"My Program"</span>) |
| .author(<span class="string">"Me, me@mail.com"</span>) |
| .version(<span class="string">"1.0.2"</span>) |
| .about(<span class="string">"Explains in brief what the program does"</span>) |
| .arg( |
| Arg::with_name(<span class="string">"in_file"</span>).index(<span class="number">1</span>) |
| ) |
| .after_help(<span class="string">"Longer explanation to appear after the options when \ |
| displaying the help information from --help or -h"</span>) |
| .get_matches(); |
| |
| <span class="comment">// Your program logic starts here...</span></code></pre></div> |
| </div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#71-1651">source</a><a href="#impl-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<'a, 'b> <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#83-87">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(n: S) -> Self</h4></section></summary><div class="docblock"><p>Creates a new instance of an application requiring a name. The name may be, but doesn’t |
| have to be same as the binary. The name will be displayed to the user when they request to |
| print version or help and usage information.</p> |
| <h5 id="examples-1"><a href="#examples-1">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>prog = App::new(<span class="string">"My Program"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_name" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#90-92">source</a><h4 class="code-header">pub fn <a href="#method.get_name" class="fnname">get_name</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Get the name of the app</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_bin_name" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#95-97">source</a><h4 class="code-header">pub fn <a href="#method.get_bin_name" class="fnname">get_bin_name</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></h4></section></summary><div class="docblock"><p>Get the name of the binary</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_defaults" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#117-124">source</a><h4 class="code-header">pub fn <a href="#method.with_defaults" class="fnname">with_defaults</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(n: S) -> Self</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 2.14.1: Can never work; use explicit App::author() and App::version() calls instead</span></div></span></summary><div class="docblock"><p>Creates a new instance of an application requiring a name, but uses the <a href="./macro.crate_authors!.html"><code>crate_authors!</code></a> |
| and <a href="./macro.crate_version!.html"><code>crate_version!</code></a> macros to fill in the <a href="./struct.App.html#method.author"><code>App::author</code></a> and <a href="./struct.App.html#method.author"><code>App::version</code></a> fields.</p> |
| <h5 id="examples-2"><a href="#examples-2">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>prog = App::with_defaults(<span class="string">"My Program"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.author" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#190-193">source</a><h4 class="code-header">pub fn <a href="#method.author" class="fnname">author</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, author: S) -> Self</h4></section></summary><div class="docblock"><p>Sets a string of author(s) that will be displayed to the user when they |
| request the help information with <code>--help</code> or <code>-h</code>.</p> |
| <p><strong>Pro-tip:</strong> Use <code>clap</code>s convenience macro <a href="./macro.crate_authors!.html"><code>crate_authors!</code></a> to automatically set your |
| application’s author(s) to the same thing as your crate at compile time. See the <a href="https://github.com/clap-rs/clap/tree/v2.33.1/examples"><code>examples/</code></a> |
| directory for more information</p> |
| <p>See the <a href="https://github.com/clap-rs/clap/tree/v2.33.1/examples"><code>examples/</code></a> |
| directory for more information</p> |
| <h5 id="examples-3"><a href="#examples-3">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .author(<span class="string">"Me, me@mymain.com"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.bin_name" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#213-216">source</a><h4 class="code-header">pub fn <a href="#method.bin_name" class="fnname">bin_name</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(self, name: S) -> Self</h4></section></summary><div class="docblock"><p>Overrides the system-determined binary name. This should only be used when absolutely |
| necessary, such as when the binary name for your application is misleading, or perhaps |
| <em>not</em> how the user should invoke your program.</p> |
| <p><strong>Pro-tip:</strong> When building things such as third party <code>cargo</code> subcommands, this setting |
| <strong>should</strong> be used!</p> |
| <p><strong>NOTE:</strong> This command <strong>should not</strong> be used for <a href="./struct.SubCommand.html"><code>SubCommand</code></a>s.</p> |
| <h5 id="examples-4"><a href="#examples-4">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"My Program"</span>) |
| .bin_name(<span class="string">"my_binary"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.about" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#236-239">source</a><h4 class="code-header">pub fn <a href="#method.about" class="fnname">about</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, about: S) -> Self</h4></section></summary><div class="docblock"><p>Sets a string describing what the program does. This will be displayed when displaying help |
| information with <code>-h</code>.</p> |
| <p><strong>NOTE:</strong> If only <code>about</code> is provided, and not <a href="./struct.App.html#method.long_about"><code>App::long_about</code></a> but the user requests |
| <code>--help</code> clap will still display the contents of <code>about</code> appropriately</p> |
| <p><strong>NOTE:</strong> Only <a href="struct.App.html#method.about" title="App::about"><code>App::about</code></a> is used in completion script generation in order to be |
| concise</p> |
| <h5 id="examples-5"><a href="#examples-5">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .about(<span class="string">"Does really amazing things to great people"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.long_about" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#262-265">source</a><h4 class="code-header">pub fn <a href="#method.long_about" class="fnname">long_about</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, about: S) -> Self</h4></section></summary><div class="docblock"><p>Sets a string describing what the program does. This will be displayed when displaying help |
| information.</p> |
| <p><strong>NOTE:</strong> If only <code>long_about</code> is provided, and not <a href="./struct.App.html#method.about"><code>App::about</code></a> but the user requests |
| <code>-h</code> clap will still display the contents of <code>long_about</code> appropriately</p> |
| <p><strong>NOTE:</strong> Only <a href="./struct.App.html#method.about"><code>App::about</code></a> is used in completion script generation in order to be |
| concise</p> |
| <h5 id="examples-6"><a href="#examples-6">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .long_about( |
| <span class="string">"Does really amazing things to great people. Now let's talk a little |
| more in depth about how this subcommand really works. It may take about |
| a few lines of text, but that's ok!"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.name" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#289-292">source</a><h4 class="code-header">pub fn <a href="#method.name" class="fnname">name</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(self, name: S) -> Self</h4></section></summary><div class="docblock"><p>Sets the program’s name. This will be displayed when displaying help information.</p> |
| <p><strong>Pro-top:</strong> This function is particularly useful when configuring a program via |
| <a href="./struct.App.html#method.from_yaml"><code>App::from_yaml</code></a> in conjunction with the <a href="./macro.crate_name.html"><code>crate_name!</code></a> macro to derive the program’s |
| name from its <code>Cargo.toml</code>.</p> |
| <h5 id="examples-7"><a href="#examples-7">Examples</a></h5> |
| <div class="example-wrap ignore"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code><span class="kw">let </span>yml = <span class="macro">load_yaml!</span>(<span class="string">"app.yml"</span>); |
| <span class="kw">let </span>app = App::from_yaml(yml) |
| .name(<span class="macro">crate_name!</span>()); |
| |
| <span class="comment">// continued logic goes here, such as `app.get_matches()` etc.</span></code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.after_help" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#306-309">source</a><h4 class="code-header">pub fn <a href="#method.after_help" class="fnname">after_help</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, help: S) -> Self</h4></section></summary><div class="docblock"><p>Adds additional help information to be displayed in addition to auto-generated help. This |
| information is displayed <strong>after</strong> the auto-generated help information. This is often used |
| to describe how to use the arguments, or caveats to be noted.</p> |
| <h5 id="examples-8"><a href="#examples-8">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .after_help(<span class="string">"Does really amazing things to great people...but be careful with -R"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.before_help" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#323-326">source</a><h4 class="code-header">pub fn <a href="#method.before_help" class="fnname">before_help</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, help: S) -> Self</h4></section></summary><div class="docblock"><p>Adds additional help information to be displayed in addition to auto-generated help. This |
| information is displayed <strong>before</strong> the auto-generated help information. This is often used |
| for header information.</p> |
| <h5 id="examples-9"><a href="#examples-9">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .before_help(<span class="string">"Some info I'd like to appear before the help info"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.version" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#349-352">source</a><h4 class="code-header">pub fn <a href="#method.version" class="fnname">version</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, ver: S) -> Self</h4></section></summary><div class="docblock"><p>Sets a string of the version number to be displayed when displaying version or help |
| information with <code>-V</code>.</p> |
| <p><strong>NOTE:</strong> If only <code>version</code> is provided, and not <a href="./struct.App.html#method.long_version"><code>App::long_version</code></a> but the user |
| requests <code>--version</code> clap will still display the contents of <code>version</code> appropriately</p> |
| <p><strong>Pro-tip:</strong> Use <code>clap</code>s convenience macro <a href="./macro.crate_version!.html"><code>crate_version!</code></a> to automatically set your |
| application’s version to the same thing as your crate at compile time. See the <a href="https://github.com/clap-rs/clap/tree/v2.33.1/examples"><code>examples/</code></a> |
| directory for more information</p> |
| <h5 id="examples-10"><a href="#examples-10">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .version(<span class="string">"v0.1.24"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.long_version" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#380-383">source</a><h4 class="code-header">pub fn <a href="#method.long_version" class="fnname">long_version</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, ver: S) -> Self</h4></section></summary><div class="docblock"><p>Sets a string of the version number to be displayed when displaying version or help |
| information with <code>--version</code>.</p> |
| <p><strong>NOTE:</strong> If only <code>long_version</code> is provided, and not <a href="./struct.App.html#method.version"><code>App::version</code></a> but the user |
| requests <code>-V</code> clap will still display the contents of <code>long_version</code> appropriately</p> |
| <p><strong>Pro-tip:</strong> Use <code>clap</code>s convenience macro <a href="./macro.crate_version!.html"><code>crate_version!</code></a> to automatically set your |
| application’s version to the same thing as your crate at compile time. See the <a href="https://github.com/clap-rs/clap/tree/v2.33.1/examples"><code>examples/</code></a> |
| directory for more information</p> |
| <h5 id="examples-11"><a href="#examples-11">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .long_version( |
| <span class="string">"v0.1.24 |
| commit: abcdef89726d |
| revision: 123 |
| release: 2 |
| binary: myprog"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.usage" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#409-412">source</a><h4 class="code-header">pub fn <a href="#method.usage" class="fnname">usage</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, usage: S) -> Self</h4></section></summary><div class="docblock"><p>Sets a custom usage string to override the auto-generated usage string.</p> |
| <p>This will be displayed to the user when errors are found in argument parsing, or when you |
| call <a href="./struct.ArgMatches.html#method.usage"><code>ArgMatches::usage</code></a></p> |
| <p><strong>CAUTION:</strong> Using this setting disables <code>clap</code>s “context-aware” usage strings. After this |
| setting is set, this will be the only usage string displayed to the user!</p> |
| <p><strong>NOTE:</strong> You do not need to specify the “USAGE: \n\t” portion, as that will |
| still be applied by <code>clap</code>, you only need to specify the portion starting |
| with the binary name.</p> |
| <p><strong>NOTE:</strong> This will not replace the entire help message, <em>only</em> the portion |
| showing the usage.</p> |
| <h5 id="examples-12"><a href="#examples-12">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .usage(<span class="string">"myapp [-clDas] <some_file>"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.help" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#448-451">source</a><h4 class="code-header">pub fn <a href="#method.help" class="fnname">help</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, help: S) -> Self</h4></section></summary><div class="docblock"><p>Sets a custom help message and overrides the auto-generated one. This should only be used |
| when the auto-generated message does not suffice.</p> |
| <p>This will be displayed to the user when they use <code>--help</code> or <code>-h</code></p> |
| <p><strong>NOTE:</strong> This replaces the <strong>entire</strong> help message, so nothing will be auto-generated.</p> |
| <p><strong>NOTE:</strong> This <strong>only</strong> replaces the help message for the current command, meaning if you |
| are using subcommands, those help messages will still be auto-generated unless you |
| specify a <a href="./struct.Arg.html#method.help"><code>Arg::help</code></a> for them as well.</p> |
| <h5 id="examples-13"><a href="#examples-13">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myapp"</span>) |
| .help(<span class="string">"myapp v1.0\n\ |
| Does awesome things\n\ |
| (C) me@mail.com\n\n\ |
| |
| USAGE: myapp <opts> <command>\n\n\ |
| |
| Options:\n\ |
| -h, --help Display this message\n\ |
| -V, --version Display version info\n\ |
| -s <stuff> Do something with stuff\n\ |
| -v Be verbose\n\n\ |
| |
| Commmands:\n\ |
| help Prints this message\n\ |
| work Do some work"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.help_short" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#474-477">source</a><h4 class="code-header">pub fn <a href="#method.help_short" class="fnname">help_short</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>> + 'b>(self, s: S) -> Self</h4></section></summary><div class="docblock"><p>Sets the <a href="./struct.Arg.html#method.short"><code>short</code></a> for the auto-generated <code>help</code> argument.</p> |
| <p>By default <code>clap</code> automatically assigns <code>h</code>, but this can be overridden if you have a |
| different argument which you’d prefer to use the <code>-h</code> short with. This can be done by |
| defining your own argument with a lowercase <code>h</code> as the <a href="./struct.Arg.html#method.short"><code>short</code></a>.</p> |
| <p><code>clap</code> lazily generates these <code>help</code> arguments <strong>after</strong> you’ve defined any arguments of |
| your own.</p> |
| <p><strong>NOTE:</strong> Any leading <code>-</code> characters will be stripped, and only the first |
| non <code>-</code> character will be used as the <a href="./struct.Arg.html#method.short"><code>short</code></a> version</p> |
| <h5 id="examples-14"><a href="#examples-14">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .help_short(<span class="string">"H"</span>) <span class="comment">// Using an uppercase `H` instead of the default lowercase `h`</span></code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.version_short" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#500-503">source</a><h4 class="code-header">pub fn <a href="#method.version_short" class="fnname">version_short</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, s: S) -> Self</h4></section></summary><div class="docblock"><p>Sets the <a href="./struct.Arg.html#method.short"><code>short</code></a> for the auto-generated <code>version</code> argument.</p> |
| <p>By default <code>clap</code> automatically assigns <code>V</code>, but this can be overridden if you have a |
| different argument which you’d prefer to use the <code>-V</code> short with. This can be done by |
| defining your own argument with an uppercase <code>V</code> as the <a href="./struct.Arg.html#method.short"><code>short</code></a>.</p> |
| <p><code>clap</code> lazily generates these <code>version</code> arguments <strong>after</strong> you’ve defined any arguments of |
| your own.</p> |
| <p><strong>NOTE:</strong> Any leading <code>-</code> characters will be stripped, and only the first |
| non <code>-</code> character will be used as the <code>short</code> version</p> |
| <h5 id="examples-15"><a href="#examples-15">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .version_short(<span class="string">"v"</span>) <span class="comment">// Using a lowercase `v` instead of the default capital `V`</span></code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.help_message" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#520-523">source</a><h4 class="code-header">pub fn <a href="#method.help_message" class="fnname">help_message</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, s: S) -> Self</h4></section></summary><div class="docblock"><p>Sets the help text for the auto-generated <code>help</code> argument.</p> |
| <p>By default <code>clap</code> sets this to <code>"Prints help information"</code>, but if you’re using a |
| different convention for your help messages and would prefer a different phrasing you can |
| override it.</p> |
| <h5 id="examples-16"><a href="#examples-16">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .help_message(<span class="string">"Print help information"</span>) <span class="comment">// Perhaps you want imperative help messages |
| </span></code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.version_message" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#538-541">source</a><h4 class="code-header">pub fn <a href="#method.version_message" class="fnname">version_message</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, s: S) -> Self</h4></section></summary><div class="docblock"><p>Sets the help text for the auto-generated <code>version</code> argument.</p> |
| <p>By default <code>clap</code> sets this to <code>"Prints version information"</code>, but if you’re using a |
| different convention for your help messages and would prefer a different phrasing then you |
| can change it.</p> |
| <h5 id="examples-17"><a href="#examples-17">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .version_message(<span class="string">"Print version information"</span>) <span class="comment">// Perhaps you want imperative help messages</span></code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.template" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#582-585">source</a><h4 class="code-header">pub fn <a href="#method.template" class="fnname">template</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, s: S) -> Self</h4></section></summary><div class="docblock"><p>Sets the help template to be used, overriding the default format.</p> |
| <p>Tags arg given inside curly brackets.</p> |
| <p>Valid tags are:</p> |
| <ul> |
| <li><code>{bin}</code> - Binary name.</li> |
| <li><code>{version}</code> - Version number.</li> |
| <li><code>{author}</code> - Author information.</li> |
| <li><code>{about}</code> - General description (from <a href="./struct.App.html#method.about"><code>App::about</code></a>)</li> |
| <li><code>{usage}</code> - Automatically generated or given usage string.</li> |
| <li><code>{all-args}</code> - Help for all arguments (options, flags, positionals arguments, |
| and subcommands) including titles.</li> |
| <li><code>{unified}</code> - Unified help for options and flags. Note, you must <em>also</em> set |
| <a href="./enum.AppSettings.html#variant.UnifiedHelpMessage"><code>AppSettings::UnifiedHelpMessage</code></a> to fully merge both options and |
| flags, otherwise the ordering is “best effort”</li> |
| <li><code>{flags}</code> - Help for flags.</li> |
| <li><code>{options}</code> - Help for options.</li> |
| <li><code>{positionals}</code> - Help for positionals arguments.</li> |
| <li><code>{subcommands}</code> - Help for subcommands.</li> |
| <li><code>{after-help}</code> - Help from <a href="./struct.App.html#method.after_help"><code>App::after_help</code></a></li> |
| <li><code>{before-help}</code> - Help from <a href="./struct.App.html#method.before_help"><code>App::before_help</code></a></li> |
| </ul> |
| <h5 id="examples-18"><a href="#examples-18">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .version(<span class="string">"1.0"</span>) |
| .template(<span class="string">"{bin} ({version}) - {usage}"</span>)</code></pre></div> |
| <p><strong>NOTE:</strong> The template system is, on purpose, very simple. Therefore the tags have to be |
| written in lowercase and without spacing.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.setting" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#602-605">source</a><h4 class="code-header">pub fn <a href="#method.setting" class="fnname">setting</a>(self, setting: <a class="enum" href="enum.AppSettings.html" title="enum clap::AppSettings">AppSettings</a>) -> Self</h4></section></summary><div class="docblock"><p>Enables a single command, or <a href="./struct.SubCommand.html"><code>SubCommand</code></a>, level settings.</p> |
| <p>See <a href="./enum.AppSettings.html"><code>AppSettings</code></a> for a full list of possibilities and examples.</p> |
| <h5 id="examples-19"><a href="#examples-19">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .setting(AppSettings::SubcommandRequired) |
| .setting(AppSettings::WaitOnError)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.settings" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#622-627">source</a><h4 class="code-header">pub fn <a href="#method.settings" class="fnname">settings</a>(self, settings: &[<a class="enum" href="enum.AppSettings.html" title="enum clap::AppSettings">AppSettings</a>]) -> Self</h4></section></summary><div class="docblock"><p>Enables multiple command, or <a href="./struct.SubCommand.html"><code>SubCommand</code></a>, level settings</p> |
| <p>See <a href="./enum.AppSettings.html"><code>AppSettings</code></a> for a full list of possibilities and examples.</p> |
| <h5 id="examples-20"><a href="#examples-20">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .settings(<span class="kw-2">&</span>[AppSettings::SubcommandRequired, |
| AppSettings::WaitOnError])</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.global_setting" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#645-649">source</a><h4 class="code-header">pub fn <a href="#method.global_setting" class="fnname">global_setting</a>(self, setting: <a class="enum" href="enum.AppSettings.html" title="enum clap::AppSettings">AppSettings</a>) -> Self</h4></section></summary><div class="docblock"><p>Enables a single setting that is propagated down through all child <a href="./struct.SubCommand.html"><code>SubCommand</code></a>s.</p> |
| <p>See <a href="./enum.AppSettings.html"><code>AppSettings</code></a> for a full list of possibilities and examples.</p> |
| <p><strong>NOTE</strong>: The setting is <em>only</em> propagated <em>down</em> and not up through parent commands.</p> |
| <h5 id="examples-21"><a href="#examples-21">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .global_setting(AppSettings::SubcommandRequired)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.global_settings" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#668-674">source</a><h4 class="code-header">pub fn <a href="#method.global_settings" class="fnname">global_settings</a>(self, settings: &[<a class="enum" href="enum.AppSettings.html" title="enum clap::AppSettings">AppSettings</a>]) -> Self</h4></section></summary><div class="docblock"><p>Enables multiple settings which are propagated <em>down</em> through all child <a href="./struct.SubCommand.html"><code>SubCommand</code></a>s.</p> |
| <p>See <a href="./enum.AppSettings.html"><code>AppSettings</code></a> for a full list of possibilities and examples.</p> |
| <p><strong>NOTE</strong>: The setting is <em>only</em> propagated <em>down</em> and not up through parent commands.</p> |
| <h5 id="examples-22"><a href="#examples-22">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .global_settings(<span class="kw-2">&</span>[AppSettings::SubcommandRequired, |
| AppSettings::ColoredHelp])</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unset_setting" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#690-693">source</a><h4 class="code-header">pub fn <a href="#method.unset_setting" class="fnname">unset_setting</a>(self, setting: <a class="enum" href="enum.AppSettings.html" title="enum clap::AppSettings">AppSettings</a>) -> Self</h4></section></summary><div class="docblock"><p>Disables a single command, or <a href="./struct.SubCommand.html"><code>SubCommand</code></a>, level setting.</p> |
| <p>See <a href="./enum.AppSettings.html"><code>AppSettings</code></a> for a full list of possibilities and examples.</p> |
| <h5 id="examples-23"><a href="#examples-23">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .unset_setting(AppSettings::ColorAuto)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unset_settings" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#710-715">source</a><h4 class="code-header">pub fn <a href="#method.unset_settings" class="fnname">unset_settings</a>(self, settings: &[<a class="enum" href="enum.AppSettings.html" title="enum clap::AppSettings">AppSettings</a>]) -> Self</h4></section></summary><div class="docblock"><p>Disables multiple command, or <a href="./struct.SubCommand.html"><code>SubCommand</code></a>, level settings.</p> |
| <p>See <a href="./enum.AppSettings.html"><code>AppSettings</code></a> for a full list of possibilities and examples.</p> |
| <h5 id="examples-24"><a href="#examples-24">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .unset_settings(<span class="kw-2">&</span>[AppSettings::ColorAuto, |
| AppSettings::AllowInvalidUtf8])</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_term_width" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#742-745">source</a><h4 class="code-header">pub fn <a href="#method.set_term_width" class="fnname">set_term_width</a>(self, width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> Self</h4></section></summary><div class="docblock"><p>Sets the terminal width at which to wrap help messages. Defaults to <code>120</code>. Using <code>0</code> will |
| ignore terminal widths and use source formatting.</p> |
| <p><code>clap</code> automatically tries to determine the terminal width on Unix, Linux, macOS and Windows |
| if the <code>wrap_help</code> cargo “feature” has been used while compiling. If the terminal width |
| cannot be determined, <code>clap</code> defaults to <code>120</code>.</p> |
| <p><strong>NOTE:</strong> This setting applies globally and <em>not</em> on a per-command basis.</p> |
| <p><strong>NOTE:</strong> This setting must be set <strong>before</strong> any subcommands are added!</p> |
| <h5 id="platform-specific"><a href="#platform-specific">Platform Specific</a></h5> |
| <p>Only Unix, Linux, macOS and Windows support automatic determination of terminal width. |
| Even on those platforms, this setting is useful if for any reason the terminal width |
| cannot be determined.</p> |
| <h5 id="examples-25"><a href="#examples-25">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .set_term_width(<span class="number">80</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.max_term_width" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#770-773">source</a><h4 class="code-header">pub fn <a href="#method.max_term_width" class="fnname">max_term_width</a>(self, w: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> Self</h4></section></summary><div class="docblock"><p>Sets the max terminal width at which to wrap help messages. Using <code>0</code> will ignore terminal |
| widths and use source formatting.</p> |
| <p><code>clap</code> automatically tries to determine the terminal width on Unix, Linux, macOS and Windows |
| if the <code>wrap_help</code> cargo “feature” has been used while compiling, but one might want to |
| limit the size (e.g. when the terminal is running fullscreen).</p> |
| <p><strong>NOTE:</strong> This setting applies globally and <em>not</em> on a per-command basis.</p> |
| <p><strong>NOTE:</strong> This setting must be set <strong>before</strong> any subcommands are added!</p> |
| <h5 id="platform-specific-1"><a href="#platform-specific-1">Platform Specific</a></h5> |
| <p>Only Unix, Linux, macOS and Windows support automatic determination of terminal width.</p> |
| <h5 id="examples-26"><a href="#examples-26">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .max_term_width(<span class="number">100</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.arg" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#796-799">source</a><h4 class="code-header">pub fn <a href="#method.arg" class="fnname">arg</a><A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="struct.Arg.html" title="struct clap::Arg">Arg</a><'a, 'b>>>(self, a: A) -> Self</h4></section></summary><div class="docblock"><p>Adds an <a href="./struct.Arg.html">argument</a> to the list of valid possibilities.</p> |
| <h5 id="examples-27"><a href="#examples-27">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| <span class="comment">// Adding a single "flag" argument with a short and help text, using Arg::with_name() |
| </span>.arg( |
| Arg::with_name(<span class="string">"debug"</span>) |
| .short(<span class="string">"d"</span>) |
| .help(<span class="string">"turns on debugging mode"</span>) |
| ) |
| <span class="comment">// Adding a single "option" argument with a short, a long, and help text using the less |
| // verbose Arg::from_usage() |
| </span>.arg( |
| Arg::from_usage(<span class="string">"-c --config=[CONFIG] 'Optionally sets a config file to use'"</span>) |
| )</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.args" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#815-820">source</a><h4 class="code-header">pub fn <a href="#method.args" class="fnname">args</a>(self, args: &[<a class="struct" href="struct.Arg.html" title="struct clap::Arg">Arg</a><'a, 'b>]) -> Self</h4></section></summary><div class="docblock"><p>Adds multiple <a href="./struct.Arg.html">arguments</a> to the list of valid possibilities</p> |
| <h5 id="examples-28"><a href="#examples-28">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .args( |
| <span class="kw-2">&</span>[Arg::from_usage(<span class="string">"[debug] -d 'turns on debugging info'"</span>), |
| Arg::with_name(<span class="string">"input"</span>).index(<span class="number">1</span>).help(<span class="string">"the input file to use"</span>)] |
| )</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.arg_from_usage" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#839-842">source</a><h4 class="code-header">pub fn <a href="#method.arg_from_usage" class="fnname">arg_from_usage</a>(self, usage: &'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> Self</h4></section></summary><div class="docblock"><p>A convenience method for adding a single <a href="./struct.Arg.html">argument</a> from a usage type string. The string |
| used follows the same rules and syntax as <a href="./struct.Arg.html#method.from_usage"><code>Arg::from_usage</code></a></p> |
| <p><strong>NOTE:</strong> The downside to using this method is that you can not set any additional |
| properties of the <a href="./struct.Arg.html"><code>Arg</code></a> other than what <a href="./struct.Arg.html#method.from_usage"><code>Arg::from_usage</code></a> supports.</p> |
| <h5 id="examples-29"><a href="#examples-29">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .arg_from_usage(<span class="string">"-c --config=<FILE> 'Sets a configuration file to use'"</span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.args_from_usage" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#866-875">source</a><h4 class="code-header">pub fn <a href="#method.args_from_usage" class="fnname">args_from_usage</a>(self, usage: &'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> Self</h4></section></summary><div class="docblock"><p>Adds multiple <a href="./struct.Arg.html">arguments</a> at once from a usage string, one per line. See |
| <a href="./struct.Arg.html#method.from_usage"><code>Arg::from_usage</code></a> for details on the syntax and rules supported.</p> |
| <p><strong>NOTE:</strong> Like <a href="./struct.App.html#method.arg_from_usage"><code>App::arg_from_usage</code></a> the downside is you only set properties for the |
| <a href="./struct.Arg.html"><code>Arg</code></a>s which <a href="./struct.Arg.html#method.from_usage"><code>Arg::from_usage</code></a> supports.</p> |
| <h5 id="examples-30"><a href="#examples-30">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .args_from_usage( |
| <span class="string">"-c --config=[FILE] 'Sets a configuration file to use' |
| [debug]... -d 'Sets the debugging level' |
| <FILE> 'The input file to use'" |
| </span>)</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.alias" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#893-900">source</a><h4 class="code-header">pub fn <a href="#method.alias" class="fnname">alias</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, name: S) -> Self</h4></section></summary><div class="docblock"><p>Allows adding a <a href="./struct.SubCommand.html"><code>SubCommand</code></a> alias, which function as “hidden” subcommands that |
| automatically dispatch as if this subcommand was used. This is more efficient, and easier |
| than creating multiple hidden subcommands as one only needs to check for the existence of |
| this command, and not all variants.</p> |
| <h5 id="examples-31"><a href="#examples-31">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>m = App::new(<span class="string">"myprog"</span>) |
| .subcommand(SubCommand::with_name(<span class="string">"test"</span>) |
| .alias(<span class="string">"do-stuff"</span>)) |
| .get_matches_from(<span class="macro">vec!</span>[<span class="string">"myprog"</span>, <span class="string">"do-stuff"</span>]); |
| <span class="macro">assert_eq!</span>(m.subcommand_name(), <span class="prelude-val">Some</span>(<span class="string">"test"</span>));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.aliases" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#922-931">source</a><h4 class="code-header">pub fn <a href="#method.aliases" class="fnname">aliases</a>(self, names: &[&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>]) -> Self</h4></section></summary><div class="docblock"><p>Allows adding <a href="./struct.SubCommand.html"><code>SubCommand</code></a> aliases, which function as “hidden” subcommands that |
| automatically dispatch as if this subcommand was used. This is more efficient, and easier |
| than creating multiple hidden subcommands as one only needs to check for the existence of |
| this command, and not all variants.</p> |
| <h5 id="examples-32"><a href="#examples-32">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>m = App::new(<span class="string">"myprog"</span>) |
| .subcommand(SubCommand::with_name(<span class="string">"test"</span>) |
| .aliases(<span class="kw-2">&</span>[<span class="string">"do-stuff"</span>, <span class="string">"do-tests"</span>, <span class="string">"tests"</span>])) |
| .arg(Arg::with_name(<span class="string">"input"</span>) |
| .help(<span class="string">"the file to add"</span>) |
| .index(<span class="number">1</span>) |
| .required(<span class="bool-val">false</span>)) |
| .get_matches_from(<span class="macro">vec!</span>[<span class="string">"myprog"</span>, <span class="string">"do-tests"</span>]); |
| <span class="macro">assert_eq!</span>(m.subcommand_name(), <span class="prelude-val">Some</span>(<span class="string">"test"</span>));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.visible_alias" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#948-955">source</a><h4 class="code-header">pub fn <a href="#method.visible_alias" class="fnname">visible_alias</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>(self, name: S) -> Self</h4></section></summary><div class="docblock"><p>Allows adding a <a href="./struct.SubCommand.html"><code>SubCommand</code></a> alias that functions exactly like those defined with |
| <a href="./struct.App.html#method.alias"><code>App::alias</code></a>, except that they are visible inside the help message.</p> |
| <h5 id="examples-33"><a href="#examples-33">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>m = App::new(<span class="string">"myprog"</span>) |
| .subcommand(SubCommand::with_name(<span class="string">"test"</span>) |
| .visible_alias(<span class="string">"do-stuff"</span>)) |
| .get_matches_from(<span class="macro">vec!</span>[<span class="string">"myprog"</span>, <span class="string">"do-stuff"</span>]); |
| <span class="macro">assert_eq!</span>(m.subcommand_name(), <span class="prelude-val">Some</span>(<span class="string">"test"</span>));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.visible_aliases" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#972-981">source</a><h4 class="code-header">pub fn <a href="#method.visible_aliases" class="fnname">visible_aliases</a>(self, names: &[&'b <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>]) -> Self</h4></section></summary><div class="docblock"><p>Allows adding multiple <a href="./struct.SubCommand.html"><code>SubCommand</code></a> aliases that functions exactly like those defined |
| with <a href="./struct.App.html#method.aliases"><code>App::aliases</code></a>, except that they are visible inside the help message.</p> |
| <h5 id="examples-34"><a href="#examples-34">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>m = App::new(<span class="string">"myprog"</span>) |
| .subcommand(SubCommand::with_name(<span class="string">"test"</span>) |
| .visible_aliases(<span class="kw-2">&</span>[<span class="string">"do-stuff"</span>, <span class="string">"tests"</span>])) |
| .get_matches_from(<span class="macro">vec!</span>[<span class="string">"myprog"</span>, <span class="string">"do-stuff"</span>]); |
| <span class="macro">assert_eq!</span>(m.subcommand_name(), <span class="prelude-val">Some</span>(<span class="string">"test"</span>));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.group" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1017-1020">source</a><h4 class="code-header">pub fn <a href="#method.group" class="fnname">group</a>(self, group: <a class="struct" href="struct.ArgGroup.html" title="struct clap::ArgGroup">ArgGroup</a><'a>) -> Self</h4></section></summary><div class="docblock"><p>Adds an <a href="./struct.ArgGroup.html"><code>ArgGroup</code></a> to the application. <a href="./struct.ArgGroup.html"><code>ArgGroup</code></a>s are a family of related arguments. |
| By placing them in a logical group, you can build easier requirement and exclusion rules. |
| For instance, you can make an entire <a href="./struct.ArgGroup.html"><code>ArgGroup</code></a> required, meaning that one (and <em>only</em> |
| one) argument from that group must be present at runtime.</p> |
| <p>You can also do things such as name an <a href="./struct.ArgGroup.html"><code>ArgGroup</code></a> as a conflict to another argument. |
| Meaning any of the arguments that belong to that group will cause a failure if present with |
| the conflicting argument.</p> |
| <p>Another added benefit of <a href="./struct.ArgGroup.html"><code>ArgGroup</code></a>s is that you can extract a value from a group instead |
| of determining exactly which argument was used.</p> |
| <p>Finally, using <a href="./struct.ArgGroup.html"><code>ArgGroup</code></a>s to ensure exclusion between arguments is another very common |
| use</p> |
| <h5 id="examples-35"><a href="#examples-35">Examples</a></h5> |
| <p>The following example demonstrates using an <a href="./struct.ArgGroup.html"><code>ArgGroup</code></a> to ensure that one, and only one, |
| of the arguments from the specified group is present at runtime.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"app"</span>) |
| .args_from_usage( |
| <span class="string">"--set-ver [ver] 'set the version manually' |
| --major 'auto increase major' |
| --minor 'auto increase minor' |
| --patch 'auto increase patch'"</span>) |
| .group(ArgGroup::with_name(<span class="string">"vers"</span>) |
| .args(<span class="kw-2">&</span>[<span class="string">"set-ver"</span>, <span class="string">"major"</span>, <span class="string">"minor"</span>,<span class="string">"patch"</span>]) |
| .required(<span class="bool-val">true</span>))</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.groups" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1047-1052">source</a><h4 class="code-header">pub fn <a href="#method.groups" class="fnname">groups</a>(self, groups: &[<a class="struct" href="struct.ArgGroup.html" title="struct clap::ArgGroup">ArgGroup</a><'a>]) -> Self</h4></section></summary><div class="docblock"><p>Adds multiple <a href="./struct.ArgGroup.html"><code>ArgGroup</code></a>s to the <a href="./struct.App.html"><code>App</code></a> at once.</p> |
| <h5 id="examples-36"><a href="#examples-36">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"app"</span>) |
| .args_from_usage( |
| <span class="string">"--set-ver [ver] 'set the version manually' |
| --major 'auto increase major' |
| --minor 'auto increase minor' |
| --patch 'auto increase patch' |
| -c [FILE] 'a config file' |
| -i [IFACE] 'an interface'"</span>) |
| .groups(<span class="kw-2">&</span>[ |
| ArgGroup::with_name(<span class="string">"vers"</span>) |
| .args(<span class="kw-2">&</span>[<span class="string">"set-ver"</span>, <span class="string">"major"</span>, <span class="string">"minor"</span>,<span class="string">"patch"</span>]) |
| .required(<span class="bool-val">true</span>), |
| ArgGroup::with_name(<span class="string">"input"</span>) |
| .args(<span class="kw-2">&</span>[<span class="string">"c"</span>, <span class="string">"i"</span>]) |
| ])</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.subcommand" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1071-1074">source</a><h4 class="code-header">pub fn <a href="#method.subcommand" class="fnname">subcommand</a>(self, subcmd: <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b>) -> Self</h4></section></summary><div class="docblock"><p>Adds a <a href="./struct.SubCommand.html"><code>SubCommand</code></a> to the list of valid possibilities. Subcommands are effectively |
| sub-<a href="./struct.App.html"><code>App</code></a>s, because they can contain their own arguments, subcommands, version, usage, |
| etc. They also function just like <a href="./struct.App.html"><code>App</code></a>s, in that they get their own auto generated help, |
| version, and usage.</p> |
| <h5 id="examples-37"><a href="#examples-37">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new(<span class="string">"myprog"</span>) |
| .subcommand(SubCommand::with_name(<span class="string">"config"</span>) |
| .about(<span class="string">"Controls configuration features"</span>) |
| .arg_from_usage(<span class="string">"<config> 'Required configuration file to use'"</span>))</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.subcommands" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1092-1100">source</a><h4 class="code-header">pub fn <a href="#method.subcommands" class="fnname">subcommands</a><I>(self, subcmds: I) -> Self<span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a><Item = <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b>>,</span></h4></section></summary><div class="docblock"><p>Adds multiple subcommands to the list of valid possibilities by iterating over an |
| <a href="https://doc.rust-lang.org/std/iter/trait.IntoIterator.html"><code>IntoIterator</code></a> of <a href="./struct.SubCommand.html"><code>SubCommand</code></a>s</p> |
| <h5 id="examples-38"><a href="#examples-38">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code>.subcommands( <span class="macro">vec!</span>[ |
| SubCommand::with_name(<span class="string">"config"</span>).about(<span class="string">"Controls configuration functionality"</span>) |
| .arg(Arg::with_name(<span class="string">"config_file"</span>).index(<span class="number">1</span>)), |
| SubCommand::with_name(<span class="string">"debug"</span>).about(<span class="string">"Controls debug functionality"</span>)])</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.display_order" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1149-1152">source</a><h4 class="code-header">pub fn <a href="#method.display_order" class="fnname">display_order</a>(self, ord: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> Self</h4></section></summary><div class="docblock"><p>Allows custom ordering of <a href="./struct.SubCommand.html"><code>SubCommand</code></a>s within the help message. Subcommands with a lower |
| value will be displayed first in the help message. This is helpful when one would like to |
| emphasise frequently used subcommands, or prioritize those towards the top of the list. |
| Duplicate values <strong>are</strong> allowed. Subcommands with duplicate display orders will be |
| displayed in alphabetical order.</p> |
| <p><strong>NOTE:</strong> The default is 999 for all subcommands.</p> |
| <h5 id="examples-39"><a href="#examples-39">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>m = App::new(<span class="string">"cust-ord"</span>) |
| .subcommand(SubCommand::with_name(<span class="string">"alpha"</span>) <span class="comment">// typically subcommands are grouped |
| // alphabetically by name. Subcommands |
| // without a display_order have a value of |
| // 999 and are displayed alphabetically with |
| // all other 999 subcommands |
| </span>.about(<span class="string">"Some help and text"</span>)) |
| .subcommand(SubCommand::with_name(<span class="string">"beta"</span>) |
| .display_order(<span class="number">1</span>) <span class="comment">// In order to force this subcommand to appear *first* |
| // all we have to do is give it a value lower than 999. |
| // Any other subcommands with a value of 1 will be displayed |
| // alphabetically with this one...then 2 values, then 3, etc. |
| </span>.about(<span class="string">"I should be first!"</span>)) |
| .get_matches_from(<span class="macro">vec!</span>[ |
| <span class="string">"cust-ord"</span>, <span class="string">"--help" |
| </span>]);</code></pre></div> |
| <p>The above example displays the following help message</p> |
| <div class="example-wrap"><pre class="language-text"><code>cust-ord |
| |
| USAGE: |
| cust-ord [FLAGS] [OPTIONS] |
| |
| FLAGS: |
| -h, --help Prints help information |
| -V, --version Prints version information |
| |
| SUBCOMMANDS: |
| beta I should be first! |
| alpha Some help and text</code></pre></div></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.print_help" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1171-1182">source</a><h4 class="code-header">pub fn <a href="#method.print_help" class="fnname">print_help</a>(&mut self) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Prints the full help message to <a href="https://doc.rust-lang.org/std/io/fn.stdout.html"><code>io::stdout()</code></a> using a <a href="https://doc.rust-lang.org/std/io/struct.BufWriter.html"><code>BufWriter</code></a> using the same |
| method as if someone ran <code>-h</code> to request the help message</p> |
| <p><strong>NOTE:</strong> clap has the ability to distinguish between “short” and “long” help messages |
| depending on if the user ran <a href="./struct.Arg.html#method.help"><code>-h</code> (short)</a> or <a href="./struct.Arg.html#method.long_help"><code>--help</code> (long)</a></p> |
| <h5 id="examples-40"><a href="#examples-40">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>app = App::new(<span class="string">"myprog"</span>); |
| app.print_help();</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.print_long_help" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1201-1205">source</a><h4 class="code-header">pub fn <a href="#method.print_long_help" class="fnname">print_long_help</a>(&mut self) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Prints the full help message to <a href="https://doc.rust-lang.org/std/io/fn.stdout.html"><code>io::stdout()</code></a> using a <a href="https://doc.rust-lang.org/std/io/struct.BufWriter.html"><code>BufWriter</code></a> using the same |
| method as if someone ran <code>--help</code> to request the help message</p> |
| <p><strong>NOTE:</strong> clap has the ability to distinguish between “short” and “long” help messages |
| depending on if the user ran <a href="./struct.Arg.html#method.help"><code>-h</code> (short)</a> or <a href="./struct.Arg.html#method.long_help"><code>--help</code> (long)</a></p> |
| <h5 id="examples-41"><a href="#examples-41">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>app = App::new(<span class="string">"myprog"</span>); |
| app.print_long_help();</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_help" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1229-1240">source</a><h4 class="code-header">pub fn <a href="#method.write_help" class="fnname">write_help</a><W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a>>(&self, w: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>W) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes the full help message to the user to a <a href="https://doc.rust-lang.org/std/io/trait.Write.html"><code>io::Write</code></a> object in the same method as if |
| the user ran <code>-h</code></p> |
| <p><strong>NOTE:</strong> clap has the ability to distinguish between “short” and “long” help messages |
| depending on if the user ran <a href="./struct.Arg.html#method.help"><code>-h</code> (short)</a> or <a href="./struct.Arg.html#method.long_help"><code>--help</code> (long)</a></p> |
| <p><strong>NOTE:</strong> There is a known bug where this method does not write propagated global arguments |
| or autogenerated arguments (i.e. the default help/version args). Prefer |
| <a href="struct.App.html#method.write_long_help" title="App::write_long_help"><code>App::write_long_help</code></a> instead if possible!</p> |
| <h5 id="examples-42"><a href="#examples-42">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io; |
| <span class="kw">let </span><span class="kw-2">mut </span>app = App::new(<span class="string">"myprog"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>out = io::stdout(); |
| app.write_help(<span class="kw-2">&mut </span>out).expect(<span class="string">"failed to write to stdout"</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_long_help" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1260-1269">source</a><h4 class="code-header">pub fn <a href="#method.write_long_help" class="fnname">write_long_help</a><W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a>>(&mut self, w: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>W) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes the full help message to the user to a <a href="https://doc.rust-lang.org/std/io/trait.Write.html"><code>io::Write</code></a> object in the same method as if |
| the user ran <code>--help</code></p> |
| <p><strong>NOTE:</strong> clap has the ability to distinguish between “short” and “long” help messages |
| depending on if the user ran <a href="./struct.Arg.html#method.help"><code>-h</code> (short)</a> or <a href="./struct.Arg.html#method.long_help"><code>--help</code> (long)</a></p> |
| <h5 id="examples-43"><a href="#examples-43">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io; |
| <span class="kw">let </span><span class="kw-2">mut </span>app = App::new(<span class="string">"myprog"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>out = io::stdout(); |
| app.write_long_help(<span class="kw-2">&mut </span>out).expect(<span class="string">"failed to write to stdout"</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_version" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1288-1290">source</a><h4 class="code-header">pub fn <a href="#method.write_version" class="fnname">write_version</a><W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a>>(&self, w: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>W) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes the version message to the user to a <a href="https://doc.rust-lang.org/std/io/trait.Write.html"><code>io::Write</code></a> object as if the user ran <code>-V</code>.</p> |
| <p><strong>NOTE:</strong> clap has the ability to distinguish between “short” and “long” version messages |
| depending on if the user ran <a href="./struct.App.html#method.version"><code>-V</code> (short)</a> or <a href="./struct.App.html#method.long_version"><code>--version</code> (long)</a></p> |
| <h5 id="examples-44"><a href="#examples-44">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io; |
| <span class="kw">let </span><span class="kw-2">mut </span>app = App::new(<span class="string">"myprog"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>out = io::stdout(); |
| app.write_version(<span class="kw-2">&mut </span>out).expect(<span class="string">"failed to write to stdout"</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_long_version" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1309-1311">source</a><h4 class="code-header">pub fn <a href="#method.write_long_version" class="fnname">write_long_version</a><W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a>>(&self, w: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>W) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes the version message to the user to a <a href="https://doc.rust-lang.org/std/io/trait.Write.html"><code>io::Write</code></a> object</p> |
| <p><strong>NOTE:</strong> clap has the ability to distinguish between “short” and “long” version messages |
| depending on if the user ran <a href="./struct.App.html#method.version"><code>-V</code> (short)</a> or <a href="./struct.App.html#method.long_version"><code>--version</code> (long)</a></p> |
| <h5 id="examples-45"><a href="#examples-45">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io; |
| <span class="kw">let </span><span class="kw-2">mut </span>app = App::new(<span class="string">"myprog"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>out = io::stdout(); |
| app.write_long_version(<span class="kw-2">&mut </span>out).expect(<span class="string">"failed to write to stdout"</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gen_completions" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1396-1404">source</a><h4 class="code-header">pub fn <a href="#method.gen_completions" class="fnname">gen_completions</a><T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsString.html" title="struct std::ffi::os_str::OsString">OsString</a>>, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(<br> &mut self,<br> bin_name: S,<br> for_shell: <a class="enum" href="enum.Shell.html" title="enum clap::Shell">Shell</a>,<br> out_dir: T<br>)</h4></section></summary><div class="docblock"><p>Generate a completions file for a specified shell at compile time.</p> |
| <p><strong>NOTE:</strong> to generate the file at compile time you must use a <code>build.rs</code> “Build Script”</p> |
| <h5 id="examples-46"><a href="#examples-46">Examples</a></h5> |
| <p>The following example generates a bash completion script via a <code>build.rs</code> script. In this |
| simple example, we’ll demo a very small application with only a single subcommand and two |
| args. Real applications could be many multiple levels deep in subcommands, and have tens or |
| potentially hundreds of arguments.</p> |
| <p>First, it helps if we separate out our <code>App</code> definition into a separate file. Whether you |
| do this as a function, or bare App definition is a matter of personal preference.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// src/cli.rs |
| |
| </span><span class="kw">use </span>clap::{App, Arg, SubCommand}; |
| |
| <span class="kw">pub fn </span>build_cli() -> App<<span class="lifetime">'static</span>, <span class="lifetime">'static</span>> { |
| App::new(<span class="string">"compl"</span>) |
| .about(<span class="string">"Tests completions"</span>) |
| .arg(Arg::with_name(<span class="string">"file"</span>) |
| .help(<span class="string">"some input file"</span>)) |
| .subcommand(SubCommand::with_name(<span class="string">"test"</span>) |
| .about(<span class="string">"tests things"</span>) |
| .arg(Arg::with_name(<span class="string">"case"</span>) |
| .long(<span class="string">"case"</span>) |
| .takes_value(<span class="bool-val">true</span>) |
| .help(<span class="string">"the case to test"</span>))) |
| }</code></pre></div> |
| <p>In our regular code, we can simply call this <code>build_cli()</code> function, then call |
| <code>get_matches()</code>, or any of the other normal methods directly after. For example:</p> |
| |
| <div class="example-wrap ignore"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code><span class="comment">// src/main.rs |
| |
| </span><span class="kw">mod </span>cli; |
| |
| <span class="kw">fn </span>main() { |
| <span class="kw">let </span>m = cli::build_cli().get_matches(); |
| |
| <span class="comment">// normal logic continues... |
| </span>}</code></pre></div> |
| <p>Next, we set up our <code>Cargo.toml</code> to use a <code>build.rs</code> build script.</p> |
| <div class="example-wrap"><pre class="language-toml"><code>build = "build.rs" |
| |
| [build-dependencies] |
| clap = "2.23"</code></pre></div> |
| <p>Next, we place a <code>build.rs</code> in our project root.</p> |
| |
| <div class="example-wrap ignore"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code><span class="kw">extern crate </span>clap; |
| |
| <span class="kw">use </span>clap::Shell; |
| |
| <span class="macro">include!</span>(<span class="string">"src/cli.rs"</span>); |
| |
| <span class="kw">fn </span>main() { |
| <span class="kw">let </span>outdir = <span class="kw">match </span>env::var_os(<span class="string">"OUT_DIR"</span>) { |
| <span class="prelude-val">None </span>=> <span class="kw">return</span>, |
| <span class="prelude-val">Some</span>(outdir) => outdir, |
| }; |
| <span class="kw">let </span><span class="kw-2">mut </span>app = build_cli(); |
| app.gen_completions(<span class="string">"myapp"</span>, <span class="comment">// We need to specify the bin name manually |
| </span>Shell::Bash, <span class="comment">// Then say which shell to build completions for |
| </span>outdir); <span class="comment">// Then say where write the completions to |
| </span>}</code></pre></div> |
| <p>Now, once we compile there will be a <code>{bin_name}.bash</code> file in the directory. |
| Assuming we compiled with debug mode, it would be somewhere similar to |
| <code><project>/target/debug/build/myapp-<hash>/out/myapp.bash</code>.</p> |
| <p>Fish shell completions will use the file format <code>{bin_name}.fish</code></p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gen_completions_to" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1438-1446">source</a><h4 class="code-header">pub fn <a href="#method.gen_completions_to" class="fnname">gen_completions_to</a><W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a>, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(<br> &mut self,<br> bin_name: S,<br> for_shell: <a class="enum" href="enum.Shell.html" title="enum clap::Shell">Shell</a>,<br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>W<br>)</h4></section></summary><div class="docblock"><p>Generate a completions file for a specified shell at runtime. Until <code>cargo install</code> can |
| install extra files like a completion script, this may be used e.g. in a command that |
| outputs the contents of the completion script, to be redirected into a file by the user.</p> |
| <h5 id="examples-47"><a href="#examples-47">Examples</a></h5> |
| <p>Assuming a separate <code>cli.rs</code> like the <a href="./struct.App.html#method.gen_completions">example above</a>, |
| we can let users generate a completion script using a command:</p> |
| |
| <div class="example-wrap ignore"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code><span class="comment">// src/main.rs |
| |
| </span><span class="kw">mod </span>cli; |
| <span class="kw">use </span>std::io; |
| |
| <span class="kw">fn </span>main() { |
| <span class="kw">let </span>matches = cli::build_cli().get_matches(); |
| |
| <span class="kw">if </span>matches.is_present(<span class="string">"generate-bash-completions"</span>) { |
| cli::build_cli().gen_completions_to(<span class="string">"myapp"</span>, Shell::Bash, <span class="kw-2">&mut </span>io::stdout()); |
| } |
| |
| <span class="comment">// normal logic continues... |
| </span>} |
| </code></pre></div> |
| <p>Usage:</p> |
| <div class="example-wrap"><pre class="language-shell"><code>$ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash</code></pre></div></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_matches" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1462-1464">source</a><h4 class="code-header">pub fn <a href="#method.get_matches" class="fnname">get_matches</a>(self) -> <a class="struct" href="struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a><'a></h4></section></summary><div class="docblock"><p>Starts the parsing process, upon a failed parse an error will be displayed to the user and |
| the process will exit with the appropriate error code. By default this method gets all user |
| provided arguments from <a href="https://doc.rust-lang.org/std/env/fn.args_os.html"><code>env::args_os</code></a> in order to allow for invalid UTF-8 code points, |
| which are legal on many platforms.</p> |
| <h5 id="examples-48"><a href="#examples-48">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>matches = App::new(<span class="string">"myprog"</span>) |
| <span class="comment">// Args and options go here... |
| </span>.get_matches();</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_matches_safe" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1491-1494">source</a><h4 class="code-header">pub fn <a href="#method.get_matches_safe" class="fnname">get_matches_safe</a>(self) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="struct" href="struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a><'a>></h4></section></summary><div class="docblock"><p>Starts the parsing process. This method will return a <a href="./type.Result.html"><code>clap::Result</code></a> type instead of exiting |
| the process on failed parse. By default this method gets matches from <a href="https://doc.rust-lang.org/std/env/fn.args_os.html"><code>env::args_os</code></a></p> |
| <p><strong>NOTE:</strong> This method WILL NOT exit when <code>--help</code> or <code>--version</code> (or short versions) are |
| used. It will return a <a href="./struct.Error.html"><code>clap::Error</code></a>, where the <a href="./struct.Error.html"><code>kind</code></a> is a |
| <a href="./enum.ErrorKind.html#variant.HelpDisplayed"><code>ErrorKind::HelpDisplayed</code></a> or <a href="./enum.ErrorKind.html#variant.VersionDisplayed"><code>ErrorKind::VersionDisplayed</code></a> respectively. You must call |
| <a href="./struct.Error.html#method.exit"><code>Error::exit</code></a> or perform a <a href="https://doc.rust-lang.org/std/process/fn.exit.html"><code>std::process::exit</code></a>.</p> |
| <h5 id="examples-49"><a href="#examples-49">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>matches = App::new(<span class="string">"myprog"</span>) |
| <span class="comment">// Args and options go here... |
| </span>.get_matches_safe() |
| .unwrap_or_else( |e| e.exit() );</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_matches_from" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1517-1540">source</a><h4 class="code-header">pub fn <a href="#method.get_matches_from" class="fnname">get_matches_from</a><I, T>(self, itr: I) -> <a class="struct" href="struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a><'a><span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a><Item = T>,<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsString.html" title="struct std::ffi::os_str::OsString">OsString</a>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span></h4></section></summary><div class="docblock"><p>Starts the parsing process. Like <a href="./struct.App.html#method.get_matches"><code>App::get_matches</code></a> this method does not return a <a href="./type.Result.html"><code>clap::Result</code></a> |
| and will automatically exit with an error message. This method, however, lets you specify |
| what iterator to use when performing matches, such as a <a href="https://doc.rust-lang.org/std/vec/struct.Vec.html"><code>Vec</code></a> of your making.</p> |
| <p><strong>NOTE:</strong> The first argument will be parsed as the binary name unless |
| <a href="./enum.AppSettings.html#variant.NoBinaryName"><code>AppSettings::NoBinaryName</code></a> is used</p> |
| <h5 id="examples-50"><a href="#examples-50">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>arg_vec = <span class="macro">vec!</span>[<span class="string">"my_prog"</span>, <span class="string">"some"</span>, <span class="string">"args"</span>, <span class="string">"to"</span>, <span class="string">"parse"</span>]; |
| |
| <span class="kw">let </span>matches = App::new(<span class="string">"myprog"</span>) |
| <span class="comment">// Args and options go here... |
| </span>.get_matches_from(arg_vec);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_matches_from_safe" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1574-1580">source</a><h4 class="code-header">pub fn <a href="#method.get_matches_from_safe" class="fnname">get_matches_from_safe</a><I, T>(self, itr: I) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="struct" href="struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a><'a>><span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a><Item = T>,<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsString.html" title="struct std::ffi::os_str::OsString">OsString</a>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span></h4></section></summary><div class="docblock"><p>Starts the parsing process. A combination of <a href="./struct.App.html#method.get_matches_from"><code>App::get_matches_from</code></a>, and |
| <a href="./struct.App.html#method.get_matches_safe"><code>App::get_matches_safe</code></a></p> |
| <p><strong>NOTE:</strong> This method WILL NOT exit when <code>--help</code> or <code>--version</code> (or short versions) are |
| used. It will return a <a href="./struct.Error.html"><code>clap::Error</code></a>, where the <a href="./struct.Error.html"><code>kind</code></a> is a <a href="./enum.ErrorKind.html#variant.HelpDisplayed"><code>ErrorKind::HelpDisplayed</code></a> |
| or <a href="./enum.ErrorKind.html#variant.VersionDisplayed"><code>ErrorKind::VersionDisplayed</code></a> respectively. You must call <a href="./struct.Error.html#method.exit"><code>Error::exit</code></a> or |
| perform a <a href="https://doc.rust-lang.org/std/process/fn.exit.html"><code>std::process::exit</code></a> yourself.</p> |
| <p><strong>NOTE:</strong> The first argument will be parsed as the binary name unless |
| <a href="./enum.AppSettings.html#variant.NoBinaryName"><code>AppSettings::NoBinaryName</code></a> is used</p> |
| <h5 id="examples-51"><a href="#examples-51">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>arg_vec = <span class="macro">vec!</span>[<span class="string">"my_prog"</span>, <span class="string">"some"</span>, <span class="string">"args"</span>, <span class="string">"to"</span>, <span class="string">"parse"</span>]; |
| |
| <span class="kw">let </span>matches = App::new(<span class="string">"myprog"</span>) |
| <span class="comment">// Args and options go here... |
| </span>.get_matches_from_safe(arg_vec) |
| .unwrap_or_else( |e| { <span class="macro">panic!</span>(<span class="string">"An error occurs: {}"</span>, e) });</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_matches_from_safe_borrow" class="method has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1603-1650">source</a><h4 class="code-header">pub fn <a href="#method.get_matches_from_safe_borrow" class="fnname">get_matches_from_safe_borrow</a><I, T>(<br> &mut self,<br> itr: I<br>) -> <a class="type" href="type.Result.html" title="type clap::Result">ClapResult</a><<a class="struct" href="struct.ArgMatches.html" title="struct clap::ArgMatches">ArgMatches</a><'a>><span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a><Item = T>,<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsString.html" title="struct std::ffi::os_str::OsString">OsString</a>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span></h4></section></summary><div class="docblock"><p>Starts the parsing process without consuming the <a href="./struct.App.html"><code>App</code></a> struct <code>self</code>. This is normally not |
| the desired functionality, instead prefer <a href="./struct.App.html#method.get_matches_from_safe"><code>App::get_matches_from_safe</code></a> which <em>does</em> |
| consume <code>self</code>.</p> |
| <p><strong>NOTE:</strong> The first argument will be parsed as the binary name unless |
| <a href="./enum.AppSettings.html#variant.NoBinaryName"><code>AppSettings::NoBinaryName</code></a> is used</p> |
| <h5 id="examples-52"><a href="#examples-52">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>arg_vec = <span class="macro">vec!</span>[<span class="string">"my_prog"</span>, <span class="string">"some"</span>, <span class="string">"args"</span>, <span class="string">"to"</span>, <span class="string">"parse"</span>]; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>app = App::new(<span class="string">"myprog"</span>); |
| <span class="comment">// Args and options go here... |
| </span><span class="kw">let </span>matches = app.get_matches_from_safe_borrow(arg_vec) |
| .unwrap_or_else( |e| { <span class="macro">panic!</span>(<span class="string">"An error occurs: {}"</span>, e) });</code></pre></div> |
| </div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1801-1805">source</a><a href="#impl-Clone-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<'a, 'b> <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1802-1804">source</a><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> Self</h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#132-134">source</a></span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">const fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Display-for-App%3C%27n%2C%20%27e%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1905-1909">source</a><a href="#impl-Display-for-App%3C%27n%2C%20%27e%3E" class="anchor"></a><h3 class="code-header">impl<'n, 'e> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'n, 'e></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/clap/app/mod.rs.html#1906-1908">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<'a, 'b> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b></h3></section><section id="impl-Send-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a href="#impl-Send-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<'a, 'b> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b></h3></section><section id="impl-Sync-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a href="#impl-Sync-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<'a, 'b> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b></h3></section><section id="impl-Unpin-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a href="#impl-Unpin-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<'a, 'b> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b></h3></section><section id="impl-UnwindSafe-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a href="#impl-UnwindSafe-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<'a, 'b> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.App.html" title="struct clap::App">App</a><'a, 'b></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#200">source</a><a href="#impl-Any-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#201">source</a><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211">source</a><a href="#impl-Borrow%3CT%3E-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220">source</a><a href="#impl-BorrowMut%3CT%3E-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#221">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#733">source</a><a href="#impl-From%3CT%3E-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#736">source</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#717">source</a><a href="#impl-Into%3CU%3E-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#725">source</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p> |
| <p>That is, this conversion is whatever the implementation of |
| <code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="From">From</a><T> for U</code> chooses to do.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#83">source</a><a href="#impl-ToOwned-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#88">source</a><a href="#method.to_owned" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#92">source</a><a href="#method.clone_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToString-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2497">source</a><a href="#impl-ToString-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T<span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_string" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2503">source</a><a href="#method.to_string" class="anchor"></a><h4 class="code-header">default fn <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string" class="fnname">to_string</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class='docblock'>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#775">source</a><a href="#impl-TryFrom%3CU%3E-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#781">source</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-App%3C%27a%2C%20%27b%3E" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#760">source</a><a href="#impl-TryInto%3CU%3E-for-App%3C%27a%2C%20%27b%3E" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#766">source</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="clap" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |