logo
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

IgnoreErrors

👎 Deprecated since 3.1.0:

Replaced with Command::ignore_errors

Deprecated, replaced with Command::ignore_errors

WaitOnError

👎 Deprecated since 3.1.0:

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

👎 Deprecated since 3.1.0:

Replaced with Command::allow_hyphen_values and Arg::is_allow_hyphen_values_set

AllowNegativeNumbers

👎 Deprecated since 3.1.0:

Replaced with Command::allow_negative_numbers and Command::is_allow_negative_numbers_set

AllArgsOverrideSelf

👎 Deprecated since 3.1.0:

Replaced with Command::args_override_self

Deprecated, replaced with Command::args_override_self

AllowMissingPositional

👎 Deprecated since 3.1.0:

Replaced with Command::allow_missing_positional and Command::is_allow_missing_positional_set

TrailingVarArg

👎 Deprecated since 3.1.0:

Replaced with Command::trailing_var_arg and Command::is_trailing_var_arg_set

DontDelimitTrailingValues

👎 Deprecated since 3.1.0:

Replaced with Command::dont_delimit_trailing_values and Command::is_dont_delimit_trailing_values_set

InferLongArgs

👎 Deprecated since 3.1.0:

Replaced with Command::infer_long_args

Deprecated, replaced with Command::infer_long_args

InferSubcommands

👎 Deprecated since 3.1.0:

Replaced with Command::infer_subcommands

Deprecated, replaced with Command::infer_subcommands

SubcommandRequired

👎 Deprecated since 3.1.0:

Replaced with Command::subcommand_required and Command::is_subcommand_required_set

SubcommandRequiredElseHelp

👎 Deprecated since 3.1.0:

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

👎 Deprecated since 3.1.0:

Replaced with Command::allow_external_subcommands and Command::is_allow_external_subcommands_set

AllowInvalidUtf8ForExternalSubcommands

👎 Deprecated since 3.1.0:

Replaced with Command::allow_invalid_utf8_for_external_subcommands and Command::is_allow_invalid_utf8_for_external_subcommands_set

UseLongFormatForHelpSubcommand

👎 Deprecated since 3.1.0:

This is now the default

Deprecated, this is now the default

SubcommandsNegateReqs

👎 Deprecated since 3.1.0:

Replaced with Command::subcommand_negates_reqs and Command::is_subcommand_negates_reqs_set

ArgsNegateSubcommands

👎 Deprecated since 3.1.0:

Replaced with Command::args_conflicts_with_subcommands and Command::is_args_conflicts_with_subcommands_set

SubcommandPrecedenceOverArg

👎 Deprecated since 3.1.0:

Replaced with Command::subcommand_precedence_over_arg and Command::is_subcommand_precedence_over_arg_set

ArgRequiredElseHelp

👎 Deprecated since 3.1.0:

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

👎 Deprecated since 3.1.0:

Replaced with Command::dont_collapse_args_in_usage and Command::is_dont_collapse_args_in_usage_set

NextLineHelp

👎 Deprecated since 3.1.0:

Replaced with Command::next_line_help and Command::is_next_line_help_set

DisableColoredHelp

👎 Deprecated since 3.1.0:

Replaced with Command::disable_colored_help and Command::is_disable_colored_help_set

DisableHelpFlag

👎 Deprecated since 3.1.0:

Replaced with Command::disable_help_flag and Command::is_disable_help_flag_set

DisableHelpSubcommand

👎 Deprecated since 3.1.0:

Replaced with Command::disable_help_subcommand and Command::is_disable_help_subcommand_set

DisableVersionFlag

👎 Deprecated since 3.1.0:

Replaced with Command::disable_version_flag and Command::is_disable_version_flag_set

PropagateVersion

👎 Deprecated since 3.1.0:

Replaced with Command::propagate_version and Command::is_propagate_version_set

Hidden

👎 Deprecated since 3.1.0:

Replaced with Command::hide and Command::is_hide_set

Deprecated, replaced with Command::hide and Command::is_hide_set

HidePossibleValues

👎 Deprecated since 3.1.0:

Replaced with Command::hide_possible_values and Arg::is_hide_possible_values_set

HelpExpected

👎 Deprecated since 3.1.0:

Replaced with Command::help_expected

Deprecated, replaced with Command::help_expected

NoBinaryName

👎 Deprecated since 3.1.0:

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

The resulting type after applying the | operator.

Performs the | operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.