Enum clap::AppSettings
source · [−]#[non_exhaustive]
pub enum AppSettings {
Show 33 variants
IgnoreErrors,
WaitOnError,
AllowHyphenValues,
AllowNegativeNumbers,
AllArgsOverrideSelf,
AllowMissingPositional,
TrailingVarArg,
DontDelimitTrailingValues,
InferLongArgs,
InferSubcommands,
SubcommandRequired,
SubcommandRequiredElseHelp,
AllowExternalSubcommands,
AllowInvalidUtf8ForExternalSubcommands,
UseLongFormatForHelpSubcommand,
SubcommandsNegateReqs,
ArgsNegateSubcommands,
SubcommandPrecedenceOverArg,
ArgRequiredElseHelp,
DeriveDisplayOrder,
DontCollapseArgsInUsage,
NextLineHelp,
DisableColoredHelp,
DisableHelpFlag,
DisableHelpSubcommand,
DisableVersionFlag,
PropagateVersion,
Hidden,
HidePossibleValues,
HelpExpected,
NoBinaryName,
NoAutoHelp,
NoAutoVersion,
// some variants omitted
}
Expand description
Application level settings, which affect how Command
operates
NOTE: When these settings are used, they apply only to current command, and are not propagated down or up through child or parent subcommands
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
IgnoreErrors
Replaced with Command::ignore_errors
Deprecated, replaced with Command::ignore_errors
WaitOnError
See documentation for how to hand-implement this
Deprecated, replace
let cmd = clap::Command::new("cmd")
.global_setting(clap::AppSettings::WaitOnError)
.arg(clap::arg!(--flag));
let m = cmd.get_matches();
with
let cmd = clap::Command::new("cmd")
.arg(clap::arg!(--flag));
let m = match cmd.try_get_matches() {
Ok(m) => m,
Err(err) => {
if err.use_stderr() {
let _ = err.print();
eprintln!("\nPress [ENTER] / [RETURN] to continue...");
use std::io::BufRead;
let mut s = String::new();
let i = std::io::stdin();
i.lock().read_line(&mut s).unwrap();
std::process::exit(2);
} else {
let _ = err.print();
std::process::exit(0);
}
}
};
AllowHyphenValues
Replaced with Command::allow_hyphen_values
and Arg::is_allow_hyphen_values_set
Deprecated, replaced with Command::allow_hyphen_values
and
Arg::is_allow_hyphen_values_set
AllowNegativeNumbers
Replaced with Command::allow_negative_numbers
and Command::is_allow_negative_numbers_set
Deprecated, replaced with Command::allow_negative_numbers
and
Command::is_allow_negative_numbers_set
AllArgsOverrideSelf
Replaced with Command::args_override_self
Deprecated, replaced with Command::args_override_self
AllowMissingPositional
Replaced with Command::allow_missing_positional
and Command::is_allow_missing_positional_set
Deprecated, replaced with Command::allow_missing_positional
and
Command::is_allow_missing_positional_set
TrailingVarArg
Replaced with Command::trailing_var_arg
and Command::is_trailing_var_arg_set
Deprecated, replaced with Command::trailing_var_arg
and Command::is_trailing_var_arg_set
DontDelimitTrailingValues
Replaced with Command::dont_delimit_trailing_values
and Command::is_dont_delimit_trailing_values_set
Deprecated, replaced with Command::dont_delimit_trailing_values
and
Command::is_dont_delimit_trailing_values_set
InferLongArgs
Replaced with Command::infer_long_args
Deprecated, replaced with Command::infer_long_args
InferSubcommands
Replaced with Command::infer_subcommands
Deprecated, replaced with Command::infer_subcommands
SubcommandRequired
Replaced with Command::subcommand_required
and Command::is_subcommand_required_set
Deprecated, replaced with Command::subcommand_required
and
Command::is_subcommand_required_set
SubcommandRequiredElseHelp
Replaced with Command::subcommand_required
combined with Command::arg_required_else_help
Deprecated, replaced with Command::subcommand_required
combined with
Command::arg_required_else_help
.
AllowExternalSubcommands
Replaced with Command::allow_external_subcommands
and Command::is_allow_external_subcommands_set
Deprecated, replaced with Command::allow_external_subcommands
and
Command::is_allow_external_subcommands_set
AllowInvalidUtf8ForExternalSubcommands
Replaced with Command::allow_invalid_utf8_for_external_subcommands
and Command::is_allow_invalid_utf8_for_external_subcommands_set
Deprecated, replaced with Command::allow_invalid_utf8_for_external_subcommands
and Command::is_allow_invalid_utf8_for_external_subcommands_set
UseLongFormatForHelpSubcommand
This is now the default
Deprecated, this is now the default
SubcommandsNegateReqs
Replaced with Command::subcommand_negates_reqs
and Command::is_subcommand_negates_reqs_set
Deprecated, replaced with Command::subcommand_negates_reqs
and
Command::is_subcommand_negates_reqs_set
ArgsNegateSubcommands
Replaced with Command::args_conflicts_with_subcommands
and Command::is_args_conflicts_with_subcommands_set
Deprecated, replaced with Command::args_conflicts_with_subcommands
and
Command::is_args_conflicts_with_subcommands_set
SubcommandPrecedenceOverArg
Replaced with Command::subcommand_precedence_over_arg
and Command::is_subcommand_precedence_over_arg_set
Deprecated, replaced with Command::subcommand_precedence_over_arg
and
Command::is_subcommand_precedence_over_arg_set
ArgRequiredElseHelp
Replaced with Command::arg_required_else_help
and Command::is_arg_required_else_help_set
Deprecated, replaced with Command::arg_required_else_help
and
Command::is_arg_required_else_help_set
DeriveDisplayOrder
Displays the arguments and subcommands
in the help message in the order that they were
declared in, and not alphabetically which is the default.
To override the declaration order, see Arg::display_order
and Command::display_order
.
Examples
Command::new("myprog")
.global_setting(AppSettings::DeriveDisplayOrder)
.get_matches();
DontCollapseArgsInUsage
Replaced with Command::dont_collapse_args_in_usage
and Command::is_dont_collapse_args_in_usage_set
Deprecated, replaced with Command::dont_collapse_args_in_usage
and
Command::is_dont_collapse_args_in_usage_set
NextLineHelp
Replaced with Command::next_line_help
and Command::is_next_line_help_set
Deprecated, replaced with Command::next_line_help
and Command::is_next_line_help_set
DisableColoredHelp
Replaced with Command::disable_colored_help
and Command::is_disable_colored_help_set
Deprecated, replaced with Command::disable_colored_help
and
Command::is_disable_colored_help_set
DisableHelpFlag
Replaced with Command::disable_help_flag
and Command::is_disable_help_flag_set
Deprecated, replaced with Command::disable_help_flag
and Command::is_disable_help_flag_set
DisableHelpSubcommand
Replaced with Command::disable_help_subcommand
and Command::is_disable_help_subcommand_set
Deprecated, replaced with Command::disable_help_subcommand
and
Command::is_disable_help_subcommand_set
DisableVersionFlag
Replaced with Command::disable_version_flag
and Command::is_disable_version_flag_set
Deprecated, replaced with Command::disable_version_flag
and
Command::is_disable_version_flag_set
PropagateVersion
Replaced with Command::propagate_version
and Command::is_propagate_version_set
Deprecated, replaced with Command::propagate_version
and Command::is_propagate_version_set
Hidden
Replaced with Command::hide
and Command::is_hide_set
Deprecated, replaced with Command::hide
and Command::is_hide_set
HidePossibleValues
Replaced with Command::hide_possible_values
and Arg::is_hide_possible_values_set
Deprecated, replaced with Command::hide_possible_values
and
Arg::is_hide_possible_values_set
HelpExpected
Replaced with Command::help_expected
Deprecated, replaced with Command::help_expected
NoBinaryName
Replaced with Command::no_binary_name
Deprecated, replaced with Command::no_binary_name
NoAutoHelp
Treat the auto-generated -h, --help
flags like any other flag, and not print the help
message.
This allows one to handle printing of the help message manually.
let result = Command::new("myprog")
.setting(AppSettings::NoAutoHelp)
.try_get_matches_from("myprog --help".split(" "));
// Normally, if `--help` is used clap prints the help message and returns an
// ErrorKind::DisplayHelp
//
// However, `--help` was treated like a normal flag
assert!(result.is_ok());
assert!(result.unwrap().is_present("help"));
NoAutoVersion
Treat the auto-generated -V, --version
flags like any other flag, and
not print the version message.
This allows one to handle printing of the version message manually.
let result = Command::new("myprog")
.version("3.0")
.setting(AppSettings::NoAutoVersion)
.try_get_matches_from("myprog --version".split(" "));
// Normally, if `--version` is used clap prints the version message and returns an
// ErrorKind::DisplayVersion
//
// However, `--version` was treated like a normal flag
assert!(result.is_ok());
assert!(result.unwrap().is_present("version"));
Trait Implementations
sourceimpl BitOr<AppSettings> for AppSettings
impl BitOr<AppSettings> for AppSettings
sourceimpl Clone for AppSettings
impl Clone for AppSettings
sourcefn clone(&self) -> AppSettings
fn clone(&self) -> AppSettings
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for AppSettings
impl Debug for AppSettings
sourceimpl PartialEq<AppSettings> for AppSettings
impl PartialEq<AppSettings> for AppSettings
impl Copy for AppSettings
impl StructuralPartialEq for AppSettings
Auto Trait Implementations
impl RefUnwindSafe for AppSettings
impl Send for AppSettings
impl Sync for AppSettings
impl Unpin for AppSettings
impl UnwindSafe for AppSettings
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more