270 lines
No EOL
20 KiB
HTML
270 lines
No EOL
20 KiB
HTML
<!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="API documentation for the Rust `AppSettings` enum in crate `clap`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, AppSettings">
|
||
|
||
<title>clap::AppSettings - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
|
||
<link rel="stylesheet" type="text/css" href="../main.css">
|
||
|
||
|
||
|
||
</head>
|
||
<body class="rustdoc">
|
||
<!--[if lte IE 8]>
|
||
<div class="warning">
|
||
This old browser is unsupported and will most likely display funky
|
||
things.
|
||
</div>
|
||
<![endif]-->
|
||
|
||
|
||
|
||
<nav class="sidebar">
|
||
|
||
<p class='location'><a href='index.html'>clap</a></p><script>window.sidebarCurrent = {name: 'AppSettings', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script>
|
||
</nav>
|
||
|
||
<nav class="sub">
|
||
<form class="search-form js-only">
|
||
<div class="search-container">
|
||
<input class="search-input" name="search"
|
||
autocomplete="off"
|
||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
||
type="search">
|
||
</div>
|
||
</form>
|
||
</nav>
|
||
|
||
<section id='main' class="content enum">
|
||
<h1 class='fqn'><span class='in-band'>Enum <a href='index.html'>clap</a>::<wbr><a class='enum' href=''>AppSettings</a></span><span class='out-of-band'><span id='render-detail'>
|
||
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
|
||
[<span class='inner'>−</span>]
|
||
</a>
|
||
</span><a id='src-282' class='srclink' href='../src/clap/app/settings.rs.html.html#95-291' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust enum'>pub enum AppSettings {
|
||
SubcommandsNegateReqs,
|
||
SubcommandRequired,
|
||
ArgRequiredElseHelp,
|
||
GlobalVersion,
|
||
VersionlessSubcommands,
|
||
UnifiedHelpMessage,
|
||
WaitOnError,
|
||
SubcommandRequiredElseHelp,
|
||
Hidden,
|
||
TrailingVarArg,
|
||
NoBinaryName,
|
||
// some variants omitted
|
||
}</pre><div class='docblock'><p>Application level settings, which affect how <code>App</code> operates</p>
|
||
</div><h2 class='variants'>Variants</h2>
|
||
<table class='variants_table'><tr><td id='variant.SubcommandsNegateReqs'><code>SubcommandsNegateReqs</code></td><td><div class='docblock'><p>Allows subcommands to override all requirements of the parent (this command). For example
|
||
if you had a subcommand or even top level application which had a required arguments that
|
||
are only required as long as there is no subcommand present.</p>
|
||
|
||
<p><strong>NOTE:</strong> This defaults to false (using subcommand does <em>not</em> negate requirements)</p>
|
||
|
||
<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>SubcommandsNegateReqs</span>)</pre>
|
||
</div></td><td></td></tr><tr><td id='variant.SubcommandRequired'><code>SubcommandRequired</code></td><td><div class='docblock'><p>Allows specifying that if no subcommand is present at runtime, error and exit gracefully</p>
|
||
|
||
<p><strong>NOTE:</strong> This defaults to false (subcommands do <em>not</em> need to be present)</p>
|
||
|
||
<h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>SubcommandRequired</span>)</pre>
|
||
</div></td><td></td></tr><tr><td id='variant.ArgRequiredElseHelp'><code>ArgRequiredElseHelp</code></td><td><div class='docblock'><p>Specifies that the help text should be displayed (and then exit gracefully), if no
|
||
arguments are present at runtime (i.e. an empty run such as, <code>$ myprog</code>.</p>
|
||
|
||
<p><strong>NOTE:</strong> Subcommands count as arguments</p>
|
||
|
||
<h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>ArgRequiredElseHelp</span>)</pre>
|
||
</div></td><td></td></tr><tr><td id='variant.GlobalVersion'><code>GlobalVersion</code></td><td><div class='docblock'><p>Uses version of the current command for all subcommands. (Defaults to false; subcommands
|
||
have independant version strings)</p>
|
||
|
||
<p><strong>NOTE:</strong> The version for the current command and this setting must be set <strong>prior</strong> to
|
||
adding any subcommands</p>
|
||
|
||
<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>version</span>(<span class='string'>"v1.1"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>GlobalVersion</span>)
|
||
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>with_name</span>(<span class='string'>"test"</span>))
|
||
.<span class='ident'>get_matches</span>();
|
||
<span class='comment'>// running `myprog test --version` will display</span>
|
||
<span class='comment'>// "myprog-test v1.1"</span></pre>
|
||
</div></td><td></td></tr><tr><td id='variant.VersionlessSubcommands'><code>VersionlessSubcommands</code></td><td><div class='docblock'><p>Disables <code>-V</code> and <code>--version</code> for all subcommands (Defaults to false; subcommands have
|
||
version flags)</p>
|
||
|
||
<p><strong>NOTE:</strong> This setting must be set <strong>prior</strong> adding any subcommands</p>
|
||
|
||
<p><strong>NOTE:</strong> Do not set this value to false, it will have undesired results!</p>
|
||
|
||
<h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>version</span>(<span class='string'>"v1.1"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>VersionlessSubcommands</span>)
|
||
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>with_name</span>(<span class='string'>"test"</span>))
|
||
.<span class='ident'>get_matches</span>();
|
||
<span class='comment'>// running `myprog test --version` will display unknown argument error</span></pre>
|
||
</div></td><td></td></tr><tr><td id='variant.UnifiedHelpMessage'><code>UnifiedHelpMessage</code></td><td><div class='docblock'><p>By default the auto-generated help message groups flags, options, and positional arguments
|
||
separately. This setting disable that and groups flags and options together presenting a
|
||
more unified help message (a la getopts or docopt style).</p>
|
||
|
||
<p><strong>NOTE:</strong> This setting is cosmetic only and does not affect any functionality.</p>
|
||
|
||
<h1 id='examples-5' class='section-header'><a href='#examples-5'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>UnifiedHelpMessage</span>)
|
||
.<span class='ident'>get_matches</span>();
|
||
<span class='comment'>// running `myprog --help` will display a unified "docopt" or "getopts" style help message</span></pre>
|
||
</div></td><td></td></tr><tr><td id='variant.WaitOnError'><code>WaitOnError</code></td><td><div class='docblock'><p>Will display a message "Press [ENTER]/[RETURN] to continue..." and wait user before
|
||
exiting</p>
|
||
|
||
<p>This is most useful when writing an application which is run from a GUI shortcut, or on
|
||
Windows where a user tries to open the binary by double-clicking instead of using the
|
||
command line (i.e. set <code>.arg_required_else_help(true)</code> and <code>.wait_on_error(true)</code> to
|
||
display the help in such a case).</p>
|
||
|
||
<p><strong>NOTE:</strong> This setting is <strong>not</strong> recursive with subcommands, meaning if you wish this
|
||
behavior for all subcommands, you must set this on each command (needing this is extremely
|
||
rare)</p>
|
||
|
||
<h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>WaitOnError</span>)</pre>
|
||
</div></td><td></td></tr><tr><td id='variant.SubcommandRequiredElseHelp'><code>SubcommandRequiredElseHelp</code></td><td><div class='docblock'><p>Specifies that the help text should be displayed (and then exit gracefully), if no
|
||
subcommands are present at runtime (i.e. an empty run such as, <code>$ myprog</code>.</p>
|
||
|
||
<p><strong>NOTE:</strong> This should <em>not</em> be used with <code>.subcommand_required()</code> as they do the same
|
||
thing, except one prints the help text, and one prints an error.</p>
|
||
|
||
<p><strong>NOTE:</strong> If the user specifies arguments at runtime, but no subcommand the help text will
|
||
still be displayed and exit. If this is <em>not</em> the desired result, consider using
|
||
<code>.arg_required_else_help()</code></p>
|
||
|
||
<h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>SubcommandRequiredElseHelp</span>)</pre>
|
||
</div></td><td></td></tr><tr><td id='variant.Hidden'><code>Hidden</code></td><td><div class='docblock'><p>Specifies that this subcommand should be hidden from help messages</p>
|
||
|
||
<h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>subcommand</span>(<span class='ident'>SubCommand</span>::<span class='ident'>with_name</span>(<span class='string'>"test"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>Hidden</span>))</pre>
|
||
</div></td><td></td></tr><tr><td id='variant.TrailingVarArg'><code>TrailingVarArg</code></td><td><div class='docblock'><p>Specifies that the final positional argument is a vararg and that <code>clap</code> should not attempt
|
||
to parse any further args.</p>
|
||
|
||
<p>The values of the trailing positional argument will contain all args from itself on.</p>
|
||
|
||
<p><strong>NOTE:</strong> The final positional argument <strong>must</strong> have <code>.multiple(true)</code> or usage token
|
||
equivalent.</p>
|
||
|
||
<h1 id='examples-9' class='section-header'><a href='#examples-9'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>let</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>TrailingVarArg</span>)
|
||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>from_usage</span>(<span class='string'>"<cmd>... 'commands to run'"</span>))
|
||
.<span class='ident'>get_matches_from</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"myprog"</span>, <span class='string'>"some_command"</span>, <span class='string'>"-r"</span>, <span class='string'>"set"</span>]);
|
||
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>m</span>.<span class='ident'>values_of</span>(<span class='string'>"cmd"</span>).<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span>[<span class='string'>"some_command"</span>, <span class='string'>"-r"</span>, <span class='string'>"set"</span>]);</pre>
|
||
</div></td><td></td></tr><tr><td id='variant.NoBinaryName'><code>NoBinaryName</code></td><td><div class='docblock'><p>Specifies that the parser should not assume the first argument passed is the binary name.
|
||
This is normally the case when using a "daemon" style mode, or an interactive CLI where one
|
||
one would not normally type the binary or program name for each command.</p>
|
||
|
||
<p><strong>NOTE:</strong> This should only be used when you absolutely know it's what you need. 99% of the
|
||
cases out there don't need this setting.</p>
|
||
|
||
<h1 id='examples-10' class='section-header'><a href='#examples-10'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>let</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='ident'>App</span>::<span class='ident'>new</span>(<span class='string'>"myprog"</span>)
|
||
.<span class='ident'>setting</span>(<span class='ident'>AppSettings</span>::<span class='ident'>NoBinaryName</span>)
|
||
.<span class='ident'>arg</span>(<span class='ident'>Arg</span>::<span class='ident'>from_usage</span>(<span class='string'>"<cmd>... 'commands to run'"</span>))
|
||
.<span class='ident'>get_matches_from</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"some_command"</span>, <span class='string'>"-r"</span>, <span class='string'>"set"</span>]);
|
||
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>m</span>.<span class='ident'>values_of</span>(<span class='string'>"cmd"</span>).<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span>[<span class='string'>"some_command"</span>, <span class='string'>"-r"</span>, <span class='string'>"set"</span>]);</pre>
|
||
</div></td><td></td></tr></table><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html' title='core::str::FromStr'>FromStr</a> for <a class='enum' href='../clap/enum.AppSettings.html' title='clap::AppSettings'>AppSettings</a></code></h3><div class='impl-items'><h4 id='associatedtype.Err' class='type'><code>type Err = <a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a></code></h4>
|
||
<h4 id='method.from_str' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#method.from_str' class='fnname'>from_str</a>(s: &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><Self, Self::Err></code></h4>
|
||
</div><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='enum' href='../clap/enum.AppSettings.html' title='clap::AppSettings'>AppSettings</a></code></h3><div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone' class='fnname'>clone</a>(&self) -> <a class='enum' href='../clap/enum.AppSettings.html' title='clap::AppSettings'>AppSettings</a></code></h4>
|
||
<h4 id='method.clone_from' class='method'><span class="since">1.0.0</span><code>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: &Self)</code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='enum' href='../clap/enum.AppSettings.html' title='clap::AppSettings'>AppSettings</a></code></h3><div class='impl-items'></div><h3 class='impl'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> for <a class='enum' href='../clap/enum.AppSettings.html' title='clap::AppSettings'>AppSettings</a></code></h3><div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.eq' class='fnname'>eq</a>(&self, __arg_0: &<a class='enum' href='../clap/enum.AppSettings.html' title='clap::AppSettings'>AppSettings</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
|
||
<h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&self, __arg_0: &<a class='enum' href='../clap/enum.AppSettings.html' title='clap::AppSettings'>AppSettings</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='enum' href='../clap/enum.AppSettings.html' title='clap::AppSettings'>AppSettings</a></code></h3><div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#method.fmt' class='fnname'>fmt</a>(&self, __arg_0: &mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -> <a class='type' href='https://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4>
|
||
</div></section>
|
||
<section id='search' class="content hidden"></section>
|
||
|
||
<section class="footer"></section>
|
||
|
||
<aside id="help" class="hidden">
|
||
<div>
|
||
<h1 class="hidden">Help</h1>
|
||
|
||
<div class="shortcuts">
|
||
<h2>Keyboard Shortcuts</h2>
|
||
|
||
<dl>
|
||
<dt>?</dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt>S</dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt>⇤</dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt>⇥</dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt>⏎</dt>
|
||
<dd>Go to active search result</dd>
|
||
</dl>
|
||
</div>
|
||
|
||
<div class="infos">
|
||
<h2>Search Tricks</h2>
|
||
|
||
<p>
|
||
Prefix searches with a type followed by a colon (e.g.
|
||
<code>fn:</code>) to restrict the search to a given type.
|
||
</p>
|
||
|
||
<p>
|
||
Accepted types are: <code>fn</code>, <code>mod</code>,
|
||
<code>struct</code>, <code>enum</code>,
|
||
<code>trait</code>, <code>type</code>, <code>macro</code>,
|
||
and <code>const</code>.
|
||
</p>
|
||
|
||
<p>
|
||
Search functions by type signature (e.g.
|
||
<code>vec -> usize</code> or <code>* -> vec</code>)
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
|
||
|
||
<script>
|
||
window.rootPath = "../";
|
||
window.currentCrate = "clap";
|
||
window.playgroundUrl = "";
|
||
</script>
|
||
<script src="../jquery.js"></script>
|
||
<script src="../main.js"></script>
|
||
|
||
<script defer src="../search-index.js"></script>
|
||
</body>
|
||
</html> |