diff --git a/clap_complete/src/shells/shell.rs b/clap_complete/src/shells/shell.rs index 9621f741e36..ff95eebb458 100644 --- a/clap_complete/src/shells/shell.rs +++ b/clap_complete/src/shells/shell.rs @@ -24,7 +24,15 @@ pub enum Shell { impl Shell { /// Deprecated, replaced with [`EnumValueParser`][clap::builder::EnumValueParser] - #[deprecated(since = "3.2.0", note = "Replaced with `EnumValueParser`")] + /// + /// Builder API: Instead of `arg.possible_values(Shell::possible_values())`, use `arg.value_parser(value_parser!(Shell))` + #[deprecated( + since = "3.2.0", + note = "Replaced with `EnumValueParser` + +Builder API: Instead of `arg.possible_values(Shell::possible_values())`, use `arg.value_parser(value_parser!(Shell))` +" + )] pub fn possible_values() -> impl Iterator> { Shell::value_variants() .iter() diff --git a/clap_derive/src/derives/args.rs b/clap_derive/src/derives/args.rs index 4195a081082..b14816f3ab1 100644 --- a/clap_derive/src/derives/args.rs +++ b/clap_derive/src/derives/args.rs @@ -302,7 +302,7 @@ pub fn gen_augment( parse_try_from_os_str(); }, ParserKind::FromFlag => quote_spanned! { func.span()=> - #[deprecated(since = "3.2.0", note = "Replaced with `#[clap(action = ArgAction::SetTrue)]`")] + #[deprecated(since = "3.2.0", note = "Replaced with `#[clap(action = ArgAction::SetTrue, default_value = , default_missing_value = )]`")] fn parse_from_flag() { } parse_from_flag(); diff --git a/src/builder/action.rs b/src/builder/action.rs index 71a91a8b1b3..acbfc5c7342 100644 --- a/src/builder/action.rs +++ b/src/builder/action.rs @@ -71,11 +71,24 @@ pub enum ArgAction { /// ``` Append, /// Deprecated, replaced with [`ArgAction::Set`] or [`ArgAction::Append`] + /// + /// Builder: Instead of `arg.action(ArgAction::StoreValue)`, + /// - Use `arg.action(ArgAction::Set)` for single-occurrence arguments + /// - Use `arg.action(ArgAction::Append)` for multiple-occurrence arguments + /// + /// Derive: opt-in to the new behavior with `#[clap(action)]` #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "Replaced with `ArgAction::Set` or `ArgAction::Append`" + note = "Replaced with `ArgAction::Set` or `ArgAction::Append` + +Derive: opt-in to the new behavior with `#[clap(action)]` + +Builder: Instead of `arg.action(ArgAction::StoreValue)`, +- Use `arg.action(ArgAction::Set)` for single-occurrence arguments +- Use `arg.action(ArgAction::Append)` for multiple-occurrence arguments +" ) )] StoreValue, @@ -84,7 +97,14 @@ pub enum ArgAction { feature = "deprecated", deprecated( since = "3.2.0", - note = "Replaced with `ArgAction::SetTrue` or `ArgAction::Count`" + note = "Replaced with `ArgAction::SetTrue` or `ArgAction::Count` + +Derive: opt-in to the new behavior with `#[clap(action)]` + +Builder: Instead of `arg.action(ArgAction::IncOccurrence)`, +- Use `arg.action(ArgAction::SetTrue)` if you just care if its set, then switch `matches.is_present` to `matches.get_flag` +- Use `arg.action(ArgAction::Count)` if you care how many times its set, then switch `matches.occurrences_of` to `matches.get_count` +" ) )] IncOccurrence, diff --git a/src/builder/app_settings.rs b/src/builder/app_settings.rs index 88bc243c420..570d23d3797 100644 --- a/src/builder/app_settings.rs +++ b/src/builder/app_settings.rs @@ -33,9 +33,21 @@ impl Default for AppFlags { #[non_exhaustive] pub enum AppSettings { /// Deprecated, replaced with [`Command::ignore_errors`] + /// + /// Derive: replace `#[clap(setting = IgnoreErrors)]` with `#[clap(ignore_errors = true)]` + /// + /// Builder: replace `cmd.setting(IgnoreErrors)` with `cmd.ignore_errors = true` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Command::ignore_errors`") + deprecated( + since = "3.1.0", + note = "Replaced with `Command::ignore_errors` + +Derive: replace `#[clap(setting = IgnoreErrors)]` with `#[clap(ignore_errors = true)]` + +Builder: replace `cmd.setting(IgnoreErrors)` with `cmd.ignore_errors(true)` +" + ) )] IgnoreErrors, @@ -81,179 +93,353 @@ pub enum AppSettings { /// Deprecated, replaced with [`Command::allow_hyphen_values`] and /// [`Arg::is_allow_hyphen_values_set`] + /// + /// Derive: replace `#[clap(setting = AllowHyphenValues)]` with `#[clap(allow_hyphen_values = true)]` + /// + /// Builder: replace `cmd.setting(AllowHyphenValues)` with `cmd.allow_hyphen_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set`" + note = "Replaced with `Command::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set` + +Derive: replace `#[clap(setting = AllowHyphenValues)]` with `#[clap(allow_hyphen_values = true)]` + +Builder: replace `cmd.setting(AllowHyphenValues)` with `cmd.allow_hyphen_values(true)` +" ) )] AllowHyphenValues, /// Deprecated, replaced with [`Command::allow_negative_numbers`] and /// [`Command::is_allow_negative_numbers_set`] + /// + /// Derive: replace `#[clap(setting = AllowNegativeNumbers)]` with `#[clap(allow_negative_numbers = true)]` + /// + /// Builder: replace `cmd.setting(AllowNegativeNumbers)` with `cmd.allow_negative_numbers(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::allow_negative_numbers` and `Command::is_allow_negative_numbers_set`" + note = "Replaced with `Command::allow_negative_numbers` and `Command::is_allow_negative_numbers_set` + +Derive: replace `#[clap(setting = AllowNegativeNumbers)]` with `#[clap(allow_negative_numbers = true)]` + +Builder: replace `cmd.setting(AllowNegativeNumbers)` with `cmd.allow_negative_numbers(true)` +" ) )] AllowNegativeNumbers, - /// Deprecated, replaced with [`Command::args_override_self`] + /// Deprecated, replaced with [`ArgAction::Set`][super::ArgAction::Set] + /// + /// The new actions (`ArgAction::Set`, `ArgAction::SetTrue`) do this by default. + /// + /// See `ArgAction::StoreValue` and `ArgAction::IncOccurrence` for how to migrate #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Command::args_override_self`") + deprecated( + since = "3.2.0", + note = "Replaced with `Arg::action(ArgAction::...)` + +The new actions (`ArgAction::Set`, `ArgAction::SetTrue`) do this by default. + +See `ArgAction::StoreValue` and `ArgAction::IncOccurrence` for how to migrate +" + ) )] AllArgsOverrideSelf, /// Deprecated, replaced with [`Command::allow_missing_positional`] and /// [`Command::is_allow_missing_positional_set`] + /// + /// Derive: replace `#[clap(setting = AllowMissingPositional)]` with `#[clap(allow_missing_positional = true)]` + /// + /// Builder: replace `cmd.setting(AllowMissingPositional)` with `cmd.allow_missing_positional(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::allow_missing_positional` and `Command::is_allow_missing_positional_set`" + note = "Replaced with `Command::allow_missing_positional` and `Command::is_allow_missing_positional_set` + +Derive: replace `#[clap(setting = AllowMissingPositional)]` with `#[clap(allow_missing_positional = true)]` + +Builder: replace `cmd.setting(AllowMissingPositional)` with `cmd.allow_missing_positional(true)` +" ) )] AllowMissingPositional, /// Deprecated, replaced with [`Command::trailing_var_arg`] and [`Command::is_trailing_var_arg_set`] + /// + /// Derive: replace `#[clap(setting = TrailingVarArg)]` with `#[clap(trailing_var_arg = true)]` + /// + /// Builder: replace `cmd.setting(TrailingVarArg)` with `cmd.trailing_var_arg(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::trailing_var_arg` and `Command::is_trailing_var_arg_set`" + note = "Replaced with `Command::trailing_var_arg` and `Command::is_trailing_var_arg_set` + +Derive: replace `#[clap(setting = TrailingVarArg)]` with `#[clap(trailing_var_arg = true)]` + +Builder: replace `cmd.setting(TrailingVarArg)` with `cmd.trailing_var_arg(true)` +" ) )] TrailingVarArg, /// Deprecated, replaced with [`Command::dont_delimit_trailing_values`] and /// [`Command::is_dont_delimit_trailing_values_set`] + /// + /// Derive: replace `#[clap(setting = DontDelimitTrailingValues)]` with `#[clap(dont_delimit_trailing_values = true)]` + /// + /// Builder: replace `cmd.setting(DontDelimitTrailingValues)` with `cmd.dont_delimit_trailing_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::dont_delimit_trailing_values` and `Command::is_dont_delimit_trailing_values_set`" + note = "Replaced with `Command::dont_delimit_trailing_values` and `Command::is_dont_delimit_trailing_values_set` + +Derive: replace `#[clap(setting = DontDelimitTrailingValues)]` with `#[clap(dont_delimit_trailing_values = true)]` + +Builder: replace `cmd.setting(DontDelimitTrailingValues)` with `cmd.dont_delimit_trailing_values(true)` +" ) )] DontDelimitTrailingValues, /// Deprecated, replaced with [`Command::infer_long_args`] + /// + /// Derive: replace `#[clap(setting = InferLongArgs)]` with `#[clap(infer_long_args = true)]` + /// + /// Builder: replace `cmd.setting(InferLongArgs)` with `cmd.infer_long_args(true)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Command::infer_long_args`") + deprecated( + since = "3.1.0", + note = "Replaced with `Command::infer_long_args` + +Derive: replace `#[clap(setting = InferLongArgs)]` with `#[clap(infer_long_args = true)]` + +Builder: replace `cmd.setting(InferLongArgs)` with `cmd.infer_long_args(true)` +" + ) )] InferLongArgs, /// Deprecated, replaced with [`Command::infer_subcommands`] + /// + /// Derive: replace `#[clap(setting = InferSubcommands)]` with `#[clap(infer_subcommands = true)]` + /// + /// Builder: replace `cmd.setting(InferSubcommands)` with `cmd.infer_subcommands(true)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Command::infer_subcommands`") + deprecated( + since = "3.1.0", + note = "Replaced with `Command::infer_subcommands` + +Derive: replace `#[clap(setting = InferSubcommands)]` with `#[clap(infer_subcommands = true)]` + +Builder: replace `cmd.setting(InferSubcommands)` with `cmd.infer_subcommands(true)` +" + ) )] InferSubcommands, /// Deprecated, replaced with [`Command::subcommand_required`] and /// [`Command::is_subcommand_required_set`] + /// + /// Derive: replace `#[clap(setting = SubcommandRequired)]` with `#[clap(subcommand_required = true)]` + /// + /// Builder: replace `cmd.setting(SubcommandRequired)` with `cmd.subcommand_required(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::subcommand_required` and `Command::is_subcommand_required_set`" + note = "Replaced with `Command::subcommand_required` and `Command::is_subcommand_required_set` + +Derive: replace `#[clap(setting = SubcommandRequired)]` with `#[clap(subcommand_required = true)]` + +Builder: replace `cmd.setting(SubcommandRequired)` with `cmd.subcommand_required(true)` +" ) )] SubcommandRequired, /// Deprecated, replaced with [`Command::subcommand_required`] combined with /// [`Command::arg_required_else_help`]. + /// + /// Derive: replace `#[clap(setting = SubcommandRequiredElseHelp)]` with `#[clap(subcommand_required = true, arg_required_else_help = true)]` + /// + /// Builder: replace `cmd.setting(SubcommandRequiredElseHelp)` with `cmd.subcommand_required(true).arg_required_else_help(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::subcommand_required` combined with `Command::arg_required_else_help`" + note = "Replaced with `Command::subcommand_required` combined with `Command::arg_required_else_help` + +Derive: replace `#[clap(setting = SubcommandRequiredElseHelp)]` with `#[clap(subcommand_required = true, arg_required_else_help = true)]` + +Builder: replace `cmd.setting(SubcommandRequiredElseHelp)` with `cmd.subcommand_required(true).arg_required_else_help(true)` +" ) )] SubcommandRequiredElseHelp, /// Deprecated, replaced with [`Command::allow_external_subcommands`] and /// [`Command::is_allow_external_subcommands_set`] + /// + /// Derive: replace `#[clap(setting = AllowExternalSubcommands)]` with `#[clap(allow_external_subcommands = true)]` + /// + /// Builder: replace `cmd.setting(AllowExternalSubcommands)` with `cmd.allow_external_subcommands(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::allow_external_subcommands` and `Command::is_allow_external_subcommands_set`" + note = "Replaced with `Command::allow_external_subcommands` and `Command::is_allow_external_subcommands_set` + +Derive: replace `#[clap(setting = AllowExternalSubcommands)]` with `#[clap(allow_external_subcommands = true)]` + +Builder: replace `cmd.setting(AllowExternalSubcommands)` with `cmd.allow_external_subcommands(true)` +" ) )] AllowExternalSubcommands, /// Deprecated, replaced with [`Command::multicall`] and [`Command::is_multicall_set`] + /// + /// Derive: replace `#[clap(setting = Multicall)]` with `#[clap(multicall = true)]` + /// + /// Builder: replace `cmd.setting(Multicall)` with `cmd.multicall(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::multicall` and `Command::is_multicall_set`" + note = "Replaced with `Command::multicall` and `Command::is_multicall_set` + +Derive: replace `#[clap(setting = Multicall)]` with `#[clap(multicall = true)]` + +Builder: replace `cmd.setting(Multicall)` with `cmd.multicall(true)` +" ) )] Multicall, /// Deprecated, replaced with [`Command::allow_invalid_utf8_for_external_subcommands`] and [`Command::is_allow_invalid_utf8_for_external_subcommands_set`] + /// + /// Derive: replace `#[clap(setting = AllowInvalidUtf8ForExternalSubcommands)]` with `#[clap(allow_invalid_utf8_for_external_subcommands = true)]` + /// + /// Builder: replace `cmd.setting(AllowInvalidUtf8ForExternalSubcommands)` with `cmd.allow_invalid_utf8_for_external_subcommands(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::allow_invalid_utf8_for_external_subcommands` and `Command::is_allow_invalid_utf8_for_external_subcommands_set`" + note = "Replaced with `Command::allow_invalid_utf8_for_external_subcommands` and `Command::is_allow_invalid_utf8_for_external_subcommands_set` + +Derive: replace `#[clap(setting = AllowInvalidUtf8ForExternalSubcommands)]` with `#[clap(allow_invalid_utf8_for_external_subcommands = true)]` + +Builder: replace `cmd.setting(AllowInvalidUtf8ForExternalSubcommands)` with `cmd.allow_invalid_utf8_for_external_subcommands(true)` +" ) )] AllowInvalidUtf8ForExternalSubcommands, /// Deprecated, this is now the default + /// + /// Derive: remove `#[clap(setting = UseLongFormatForHelpSubcommand)]` + /// + /// Builder: remove `cmd.setting(UseLongFormatForHelpSubcommand)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "This is now the default") + deprecated( + since = "3.1.0", + note = "This is now the default + +Derive: remove `#[clap(setting = UseLongFormatForHelpSubcommand)]` + +Builder: remove `cmd.setting(UseLongFormatForHelpSubcommand)` +" + ) )] UseLongFormatForHelpSubcommand, /// Deprecated, replaced with [`Command::subcommand_negates_reqs`] and /// [`Command::is_subcommand_negates_reqs_set`] + /// + /// Derive: replace `#[clap(setting = SubcommandsNegateReqs)]` with `#[clap(subcommand_negates_reqs = true)]` + /// + /// Builder: replace `cmd.setting(SubcommandsNegateReqs)` with `cmd.subcommand_negates_reqs(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::subcommand_negates_reqs` and `Command::is_subcommand_negates_reqs_set`" + note = "Replaced with `Command::subcommand_negates_reqs` and `Command::is_subcommand_negates_reqs_set` + +Derive: replace `#[clap(setting = SubcommandsNegateReqs)]` with `#[clap(subcommand_negates_reqs = true)]` + +Builder: replace `cmd.setting(SubcommandsNegateReqs)` with `cmd.subcommand_negates_reqs(true)` +" ) )] SubcommandsNegateReqs, /// Deprecated, replaced with [`Command::args_conflicts_with_subcommands`] and /// [`Command::is_args_conflicts_with_subcommands_set`] + /// + /// Derive: replace `#[clap(setting = ArgsNegateSubcommands)]` with `#[clap(args_conflicts_with_subcommands = true)]` + /// + /// Builder: replace `cmd.setting(ArgsNegateSubcommands)` with `cmd.args_conflicts_with_subcommands(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::args_conflicts_with_subcommands` and `Command::is_args_conflicts_with_subcommands_set`" + note = "Replaced with `Command::args_conflicts_with_subcommands` and `Command::is_args_conflicts_with_subcommands_set` + +Derive: replace `#[clap(setting = ArgsNegateSubcommands)]` with `#[clap(args_conflicts_with_subcommands = true)]` + +Builder: replace `cmd.setting(ArgsNegateSubcommands)` with `cmd.args_conflicts_with_subcommands(true)` +" ) )] ArgsNegateSubcommands, /// Deprecated, replaced with [`Command::subcommand_precedence_over_arg`] and /// [`Command::is_subcommand_precedence_over_arg_set`] + /// + /// Derive: replace `#[clap(setting = SubcommandPrecedenceOverArg)]` with `#[clap(subcommand_precedence_over_arg = true)]` + /// + /// Builder: replace `cmd.setting(SubcommandPrecedenceOverArg)` with `cmd.subcommand_precedence_over_arg(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::subcommand_precedence_over_arg` and `Command::is_subcommand_precedence_over_arg_set`" + note = "Replaced with `Command::subcommand_precedence_over_arg` and `Command::is_subcommand_precedence_over_arg_set` + +Derive: replace `#[clap(setting = SubcommandPrecedenceOverArg)]` with `#[clap(subcommand_precedence_over_arg = true)]` + +Builder: replace `cmd.setting(SubcommandPrecedenceOverArg)` with `cmd.subcommand_precedence_over_arg(true)` +" ) )] SubcommandPrecedenceOverArg, /// Deprecated, replaced with [`Command::arg_required_else_help`] and /// [`Command::is_arg_required_else_help_set`] + /// + /// Derive: replace `#[clap(setting = ArgRequiredElseHelp)]` with `#[clap(arg_required_else_help = true)]` + /// + /// Builder: replace `cmd.setting(ArgRequiredElseHelp)` with `cmd.arg_required_else_help(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::arg_required_else_help` and `Command::is_arg_required_else_help_set`" + note = "Replaced with `Command::arg_required_else_help` and `Command::is_arg_required_else_help_set` + +Derive: replace `#[clap(setting = ArgRequiredElseHelp)]` with `#[clap(arg_required_else_help = true)]` + +Builder: replace `cmd.setting(ArgRequiredElseHelp)` with `cmd.arg_required_else_help(true)` +" ) )] ArgRequiredElseHelp, @@ -279,192 +465,411 @@ pub enum AppSettings { /// Deprecated, replaced with [`Command::dont_collapse_args_in_usage`] and /// [`Command::is_dont_collapse_args_in_usage_set`] + /// + /// Derive: replace `#[clap(setting = DontCollapseArgsInUsage)]` with `#[clap(dont_collapse_args_in_usage = true)]` + /// + /// Builder: replace `cmd.setting(DontCollapseArgsInUsage)` with `cmd.dont_collapse_args_in_usage(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::dont_collapse_args_in_usage` and `Command::is_dont_collapse_args_in_usage_set`" + note = "Replaced with `Command::dont_collapse_args_in_usage` and `Command::is_dont_collapse_args_in_usage_set` + +Derive: replace `#[clap(setting = DontCollapseArgsInUsage)]` with `#[clap(dont_collapse_args_in_usage = true)]` + +Builder: replace `cmd.setting(DontCollapseArgsInUsage)` with `cmd.dont_collapse_args_in_usage(true)` +" ) )] DontCollapseArgsInUsage, /// Deprecated, replaced with [`Command::next_line_help`] and [`Command::is_next_line_help_set`] + /// + /// Derive: replace `#[clap(setting = NextLineHelp)]` with `#[clap(next_line_help = true)]` + /// + /// Builder: replace `cmd.setting(NextLineHelp)` with `cmd.next_line_help(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::next_line_help` and `Command::is_next_line_help_set`" + note = "Replaced with `Command::next_line_help` and `Command::is_next_line_help_set` + +Derive: replace `#[clap(setting = NextLineHelp)]` with `#[clap(next_line_help = true)]` + +Builder: replace `cmd.setting(NextLineHelp)` with `cmd.next_line_help(true)` +" ) )] NextLineHelp, /// Deprecated, replaced with [`Command::disable_colored_help`] and /// [`Command::is_disable_colored_help_set`] + /// + /// Derive: replace `#[clap(setting = DisableColoredHelp)]` with `#[clap(disable_colored_help = true)]` + /// + /// Builder: replace `cmd.setting(DisableColoredHelp)` with `cmd.disable_colored_help(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::disable_colored_help` and `Command::is_disable_colored_help_set`" + note = "Replaced with `Command::disable_colored_help` and `Command::is_disable_colored_help_set` + +Derive: replace `#[clap(setting = DisableColoredHelp)]` with `#[clap(disable_colored_help = true)]` + +Builder: replace `cmd.setting(DisableColoredHelp)` with `cmd.disable_colored_help(true)` +" ) )] DisableColoredHelp, /// Deprecated, replaced with [`Command::disable_help_flag`] and [`Command::is_disable_help_flag_set`] + /// + /// Derive: replace `#[clap(setting = DisableHelpFlag)]` with `#[clap(disable_help_flag = true)]` + /// + /// Builder: replace `cmd.setting(DisableHelpFlag)` with `cmd.disable_help_flag(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::disable_help_flag` and `Command::is_disable_help_flag_set`" + note = "Replaced with `Command::disable_help_flag` and `Command::is_disable_help_flag_set` + +Derive: replace `#[clap(setting = DisableHelpFlag)]` with `#[clap(disable_help_flag = true)]` + +Builder: replace `cmd.setting(DisableHelpFlag)` with `cmd.disable_help_flag(true)` +" ) )] DisableHelpFlag, /// Deprecated, replaced with [`Command::disable_help_subcommand`] and /// [`Command::is_disable_help_subcommand_set`] + /// + /// Derive: replace `#[clap(setting = DisableHelpSubcommand)]` with `#[clap(disable_help_subcommand = true)]` + /// + /// Builder: replace `cmd.setting(DisableHelpSubcommand)` with `cmd.disable_help_subcommand(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::disable_help_subcommand` and `Command::is_disable_help_subcommand_set`" + note = "Replaced with `Command::disable_help_subcommand` and `Command::is_disable_help_subcommand_set` + +Derive: replace `#[clap(setting = DisableHelpSubcommand)]` with `#[clap(disable_help_subcommand = true)]` + +Builder: replace `cmd.setting(DisableHelpSubcommand)` with `cmd.disable_help_subcommand(true)` +" ) )] DisableHelpSubcommand, /// Deprecated, replaced with [`Command::disable_version_flag`] and /// [`Command::is_disable_version_flag_set`] + /// + /// Derive: replace `#[clap(setting = DisableVersionFlag)]` with `#[clap(disable_version_flag = true)]` + /// + /// Builder: replace `cmd.setting(DisableVersionFlag)` with `cmd.disable_version_flag(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::disable_version_flag` and `Command::is_disable_version_flag_set`" + note = "Replaced with `Command::disable_version_flag` and `Command::is_disable_version_flag_set` + +Derive: replace `#[clap(setting = DisableVersionFlag)]` with `#[clap(disable_version_flag = true)]` + +Builder: replace `cmd.setting(DisableVersionFlag)` with `cmd.disable_version_flag(true)` +" ) )] DisableVersionFlag, /// Deprecated, replaced with [`Command::propagate_version`] and [`Command::is_propagate_version_set`] + /// + /// Derive: replace `#[clap(setting = PropagateVersion)]` with `#[clap(propagate_version = true)]` + /// + /// Builder: replace `cmd.setting(PropagateVersion)` with `cmd.propagate_version(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::propagate_version` and `Command::is_propagate_version_set`" + note = "Replaced with `Command::propagate_version` and `Command::is_propagate_version_set` + +Derive: replace `#[clap(setting = PropagateVersion)]` with `#[clap(propagate_version = true)]` + +Builder: replace `cmd.setting(PropagateVersion)` with `cmd.propagate_version(true)` +" ) )] PropagateVersion, /// Deprecated, replaced with [`Command::hide`] and [`Command::is_hide_set`] + /// + /// Derive: replace `#[clap(setting = Hidden)]` with `#[clap(hide = true)]` + /// + /// Builder: replace `cmd.setting(Hidden)` with `cmd.hide(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::hide` and `Command::is_hide_set`" + note = "Replaced with `Command::hide` and `Command::is_hide_set` + +Derive: replace `#[clap(setting = Hidden)]` with `#[clap(hide = true)]` + +Builder: replace `cmd.setting(Hidden)` with `cmd.hide(true)` +" ) )] Hidden, /// Deprecated, replaced with [`Command::hide_possible_values`] and /// [`Arg::is_hide_possible_values_set`] + /// + /// Derive: replace `#[clap(setting = HidePossibleValues)]` with `#[clap(hide_possible_values = true)]` + /// + /// Builder: replace `cmd.setting(HidePossibleValues)` with `cmd.hide_possible_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Command::hide_possible_values` and `Arg::is_hide_possible_values_set`" + note = "Replaced with `Command::hide_possible_values` and `Arg::is_hide_possible_values_set` + +Derive: replace `#[clap(setting = HidePossibleValues)]` with `#[clap(hide_possible_values = true)]` + +Builder: replace `cmd.setting(HidePossibleValues)` with `cmd.hide_possible_values(true)` +" ) )] HidePossibleValues, /// Deprecated, replaced with [`Command::help_expected`] + /// + /// Derive: replace `#[clap(setting = HelpExpected)]` with `#[clap(help_expected = true)]` + /// + /// Builder: replace `cmd.setting(HelpExpected)` with `cmd.help_expected(true)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Command::help_expected`") + deprecated( + since = "3.1.0", + note = "Replaced with `Command::help_expected` + +Derive: replace `#[clap(setting = HelpExpected)]` with `#[clap(help_expected = true)]` + +Builder: replace `cmd.setting(HelpExpected)` with `cmd.help_expected(true)` +" + ) )] HelpExpected, /// Deprecated, replaced with [`Command::no_binary_name`] + /// + /// Derive: replace `#[clap(setting = NoBinaryName)]` with `#[clap(no_binary_name = true)]` + /// + /// Builder: replace `cmd.setting(NoBinaryName)` with `cmd.no_binary_name(true)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Command::no_binary_name`") + deprecated( + since = "3.1.0", + note = "Replaced with `Command::no_binary_name` + +Derive: replace `#[clap(setting = NoBinaryName)]` with `#[clap(no_binary_name = true)]` + +Builder: replace `cmd.setting(NoBinaryName)` with `cmd.no_binary_name(true)` +" + ) )] NoBinaryName, /// Deprecated, replaced with [`Arg::action`][super::Arg::action] + /// + /// Derive: replace `#[clap(setting = NoAutoHelp)]` with setting an explicit action on your help argument + /// + /// Builder: replace `cmd.setting(NoAutoHelp)` with setting an explicit action on your help argument #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `Arg::action`") + deprecated( + since = "3.2.0", + note = "Replaced with `Arg::action` + +Derive: replace `#[clap(setting = NoAutoHelp)]` with setting an explicit action on your help argument + +Builder: replace `cmd.setting(NoAutoHelp)` with setting an explicit action on your help argument +" + ) )] NoAutoHelp, /// Deprecated, replaced with [`Arg::action`][super::Arg::action] + /// + /// Derive: replace `#[clap(setting = NoAutoVersion)]` with setting an explicit action on your version argument + /// + /// Builder: replace `cmd.setting(NoAutoVersion)` with setting an explicit action on your version argument #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `Arg::action`") + deprecated( + since = "3.2.0", + note = "Replaced with `Arg::action` + +Derive: replace `#[clap(setting = NoAutoVersion)]` with setting an explicit action on your version argument + +Builder: replace `cmd.setting(NoAutoVersion)` with setting an explicit action on your version argument +" + ) )] NoAutoVersion, /// Deprecated, replaced with [`Command::allow_hyphen_values`] + /// + /// Derive: replace `#[clap(setting = AllowLeadingHyphen)]` with `#[clap(allow_hyphen_values = true)]` + /// + /// Builder: replace `cmd.setting(AllowLeadingHyphen)` with `cmd.allow_hyphen_values(true)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "Replaced with `Command::allow_hyphen_values`") + deprecated( + since = "3.0.0", + note = "Replaced with `Command::allow_hyphen_values` + +Derive: replace `#[clap(setting = AllowLeadingHyphen)]` with `#[clap(allow_hyphen_values = true)]` + +Builder: replace `cmd.setting(AllowLeadingHyphen)` with `cmd.allow_hyphen_values(true)` +" + ) )] #[doc(hidden)] AllowLeadingHyphen, /// Deprecated, replaced with [`Command::allow_invalid_utf8_for_external_subcommands`] and [`Command::is_allow_invalid_utf8_for_external_subcommands_set`] + /// + /// Derive: replace `#[clap(setting = StrictUtf8)]` with `#[clap(allow_invalid_utf8_for_external_subcommands = true)]` + /// + /// Builder: replace `cmd.setting(StrictUtf8)` with `cmd.allow_invalid_utf8_for_external_subcommands(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `Command::allow_invalid_utf8_for_external_subcommands` and `Command::is_allow_invalid_utf8_for_external_subcommands_set`" + note = "Replaced with `Command::allow_invalid_utf8_for_external_subcommands` and `Command::is_allow_invalid_utf8_for_external_subcommands_set` + +Derive: replace `#[clap(setting = StrictUtf8)]` with `#[clap(allow_invalid_utf8_for_external_subcommands = true)]` + +Builder: replace `cmd.setting(StrictUtf8)` with `cmd.allow_invalid_utf8_for_external_subcommands(true)` +" ) )] #[doc(hidden)] StrictUtf8, /// Deprecated, this is now the default + /// + /// Derive: remove `#[clap(setting = UnifiedHelpMessage)]` + /// + /// Builder: remove `cmd.setting(UnifiedHelpMessage)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "This is now the default") + deprecated( + since = "3.0.0", + note = "This is now the default + +Derive: remove `#[clap(setting = UnifiedHelpMessage)]` + +Builder: remove `cmd.setting(UnifiedHelpMessage)` +" + ) )] #[doc(hidden)] UnifiedHelpMessage, /// Deprecated, this is now the default + /// + /// Derive: remove `#[clap(setting = ColoredHelp)]` + /// + /// Builder: remove `cmd.setting(ColoredHelp)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "This is now the default") + deprecated( + since = "3.0.0", + note = "This is now the default + +Derive: remove `#[clap(setting = ColoredHelp)]` + +Builder: remove `cmd.setting(ColoredHelp)` +" + ) )] #[doc(hidden)] ColoredHelp, /// Deprecated, see [`Command::color`][crate::Command::color] + /// + /// Derive: replace `#[clap(setting = ColorAuto)]` with `#[clap(color = ColorChoice::Auto)]`` + /// + /// Builder: replace `cmd.setting(ColorAuto)` with `cmd.color(Color::Auto)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "Replaced with `Command::color`") + deprecated( + since = "3.0.0", + note = "Replaced with `Command::color` + +Derive: replace `#[clap(setting = ColorAuto)]` with `#[clap(color = ColorChoice::Auto)]`` + +Builder: replace `cmd.setting(ColorAuto)` with `cmd.color(Color::Auto)` +" + ) )] #[doc(hidden)] ColorAuto, /// Deprecated, replaced with [`Command::color`][crate::Command::color] + /// + /// Derive: replace `#[clap(setting = ColorAlways)]` with `#[clap(color = ColorChoice::Always)]`` + /// + /// Builder: replace `cmd.setting(ColorAlways)` with `cmd.color(Color::Always)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "Replaced with `Command::color`") + deprecated( + since = "3.0.0", + note = "Replaced with `Command::color` + +Derive: replace `#[clap(setting = ColorAlways)]` with `#[clap(color = ColorChoice::Always)]`` + +Builder: replace `cmd.setting(ColorAlways)` with `cmd.color(Color::Always)` +" + ) )] #[doc(hidden)] ColorAlways, /// Deprecated, replaced with [`Command::color`][crate::Command::color] + /// + /// Derive: replace `#[clap(setting = ColorNever)]` with `#[clap(color = ColorChoice::Never)]`` + /// + /// Builder: replace `cmd.setting(ColorNever)` with `cmd.color(Color::Never)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "Replaced with `Command::color`") + deprecated( + since = "3.0.0", + note = "Replaced with `Command::color` + +Derive: replace `#[clap(setting = ColorNever)]` with `#[clap(color = ColorChoice::Never)]`` + +Builder: replace `cmd.setting(ColorNever)` with `cmd.color(Color::Never)` +" + ) )] #[doc(hidden)] ColorNever, /// Deprecated, replaced with [`Command::disable_help_flag`] and [`Command::is_disable_help_flag_set`] + /// + /// Derive: replace `#[clap(setting = DisableHelpFlags)]` with `#[clap(disable_help_flag = true)]` + /// + /// Builder: replace `cmd.setting(DisableHelpFlags)` with `cmd.disable_help_flag(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `Command::disable_help_flag` and `Command::is_disable_help_flag_set`" + note = "Replaced with `Command::disable_help_flag` and `Command::is_disable_help_flag_set` + +Derive: replace `#[clap(setting = DisableHelpFlags)]` with `#[clap(disable_help_flag = true)]` + +Builder: replace `cmd.setting(DisableHelpFlags)` with `cmd.disable_help_flag(true)` +" ) )] #[doc(hidden)] @@ -472,22 +877,40 @@ pub enum AppSettings { /// Deprecated, replaced with [`Command::disable_version_flag`] and /// [`Command::is_disable_version_flag_set`] + /// + /// Derive: replace `#[clap(setting = DisableVersion)]` with `#[clap(disable_version_flag = true)]` + /// + /// Builder: replace `cmd.setting(DisableVersion)` with `cmd.disable_version_flag(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `Command::disable_version_flag` and `Command::is_disable_version_flag_set`" + note = "Replaced with `Command::disable_version_flag` and `Command::is_disable_version_flag_set` + +Derive: replace `#[clap(setting = DisableVersion)]` with `#[clap(disable_version_flag = true)]` + +Builder: replace `cmd.setting(DisableVersion)` with `cmd.disable_version_flag(true)` +" ) )] #[doc(hidden)] DisableVersion, /// Deprecated, replaced with [`Command::propagate_version`] and [`Command::is_propagate_version_set`] + /// + /// Derive: replace `#[clap(setting = GlobalVersion)]` with `#[clap(propagate_version = true)]` + /// + /// Builder: replace `cmd.setting(GlobalVersion)` with `cmd.propagate_version(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `Command::propagate_version` and `Command::is_propagate_version_set`" + note = "Replaced with `Command::propagate_version` and `Command::is_propagate_version_set` + +Derive: replace `#[clap(setting = GlobalVersion)]` with `#[clap(propagate_version = true)]` + +Builder: replace `cmd.setting(GlobalVersion)` with `cmd.propagate_version(true)` +" ) )] #[doc(hidden)] @@ -495,20 +918,41 @@ pub enum AppSettings { /// Deprecated, replaced with [`Command::hide_possible_values`] and /// [`Arg::is_hide_possible_values_set`] + /// + /// Derive: replace `#[clap(setting = HidePossibleValuesInHelp)]` with `#[clap(hide_possible_values = true)]` + /// + /// Builder: replace `cmd.setting(HidePossibleValuesInHelp)` with `cmd.hide_possible_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `Command::hide_possible_values` and `Arg::is_hide_possible_values_set`" + note = "Replaced with `Command::hide_possible_values` and `Arg::is_hide_possible_values_set` + +Derive: replace `#[clap(setting = HidePossibleValuesInHelp)]` with `#[clap(hide_possible_values = true)]` + +Builder: replace `cmd.setting(HidePossibleValuesInHelp)` with `cmd.hide_possible_values(true)` +" ) )] #[doc(hidden)] HidePossibleValuesInHelp, /// Deprecated, this is now the default + /// + /// Derive: remove `#[clap(setting = UnifiedHelp)]` + /// + /// Builder: remove `cmd.setting(UnifiedHelp)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "This is now the default") + deprecated( + since = "3.0.0", + note = "This is now the default + +Derive: remove `#[clap(setting = UnifiedHelp)]` + +Builder: remove `cmd.setting(UnifiedHelp)` +" + ) )] #[doc(hidden)] UnifiedHelp, diff --git a/src/builder/arg.rs b/src/builder/arg.rs index e9403d0b70d..fb42d87e2dc 100644 --- a/src/builder/arg.rs +++ b/src/builder/arg.rs @@ -134,10 +134,18 @@ impl<'help> Arg<'help> { self } - /// Deprecated, replaced with [`Arg::id`] + /// Deprecated, replaced with [`Arg::id`] to avoid confusion with [`Arg::value_name`] + /// + /// Builder: replaced `arg.name(...)` with `arg.id(...)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Arg::id`") + deprecated( + since = "3.1.0", + note = "Replaced with `Arg::id` to avoid confusion with `Arg::value_name` + +Builder: replaced `arg.name(...)` with `arg.id(...)` +" + ) )] pub fn name>(self, n: S) -> Self { self.id(n) @@ -790,7 +798,13 @@ impl<'help> Arg<'help> { #[must_use] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `Arg::action` (Issue #3772)") + deprecated( + since = "3.2.0", + note = "Replaced with `Arg::action` (Issue #3772) + +Builder: replace `arg.multiple_occurrences(true)` with `arg.action(ArgAction::Append)` when taking a value and `arg.action(ArgAction::Count)` with `matches.get_count` when not +" + ) )] pub fn multiple_occurrences(self, yes: bool) -> Self { if yes { @@ -800,14 +814,23 @@ impl<'help> Arg<'help> { } } - /// Deprecated, for flags this is replaced with `action(ArgAction::Count).value_parser(value_parser!(u8).range(..max))` + /// Deprecated, for flags, this is replaced with `RangedI64ValueParser::range` + /// + /// Derive: `#[clap(action = ArgAction::Count, value_parser = value_parser!(u8).range(..max))]` + /// + /// Builder: `arg.action(ArgAction::Count).value_parser(value_parser!(u8).range(..max))` #[inline] #[must_use] #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "For flags, replaced with `action(ArgAction::Count).value_parser(value_parser!(u8).range(..max))`" + note = "For flags, this is replaced with `RangedI64ValueParser::range` + +Derive: `#[clap(action = ArgAction::Count, value_parser = value_parser!(u8).range(..max))]` + +Builder: `arg.action(ArgAction::Count).value_parser(value_parser!(u8).range(..max))` +" ) )] pub fn max_occurrences(mut self, qty: usize) -> Self { @@ -1516,11 +1539,25 @@ impl<'help> Arg<'help> { } /// Deprecated, replaced with [`Arg::value_parser(...)`] + /// + /// Derive: replace `#[clap(validator = ...)]` with `#[clap(value_parser = ...)]` + /// + /// Builder: replace `arg.validator(...)` with `arg.value_parser(...)` and `matches.value_of` with + /// `matches.get_one::` or `matches.values_of` with `matches.get_many::` #[inline] #[must_use] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `Arg::value_parser(...)`") + deprecated( + since = "3.2.0", + note = "Replaced with `Arg::value_parser(...)` + +Derive: replace `#[clap(validator = )]` with `#[clap(value_parser = )]` + +Builder: replace `arg.validator()` with `arg.value_parser()` and `matches.value_of` with +`matches.get_one::` or `matches.values_of` with `matches.get_many::` +" + ) )] pub fn validator(mut self, mut f: F) -> Self where @@ -1537,7 +1574,16 @@ impl<'help> Arg<'help> { #[must_use] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `Arg::value_parser(...)`") + deprecated( + since = "3.2.0", + note = "Replaced with `Arg::value_parser(...)` + +Derive: replace `#[clap(validator = )]` with `#[clap(value_parser = )]` + +Builder: replace `arg.validator()` with `arg.value_parser()` and `matches.value_of_os` with +`matches.get_one::` or `matches.values_of_os` with `matches.get_many::` +" + ) )] pub fn validator_os(mut self, mut f: F) -> Self where @@ -1551,11 +1597,20 @@ impl<'help> Arg<'help> { } /// Deprecated in [Issue #3743](https://github.com/clap-rs/clap/issues/3743), replaced with [`Arg::value_parser(...)`] + /// + /// Derive: replace `#[clap(validator_regex = ...)]` with `#[clap(value_parser = |s: &str| regex.is_match(s).then(|| s.to_owned()).ok_or_else(|| ...))]` + /// + /// Builder: replace `arg.validator_regex(...)` with `arg.value_parser(|s: &str| regex.is_match(s).then(|| s.to_owned()).ok_or_else(|| ...))` #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "Deprecated in Issue #3743; eplaced with `Arg::value_parser(...)`" + note = "Deprecated in Issue #3743; replaced with `Arg::value_parser(...)` + +Derive: replace `#[clap(validator_regex = ...)]` with `#[clap(value_parser = |s: &str| regex.is_match(s).then(|| s.to_owned()).ok_or_else(|| ...))]` + +Builder: replace `arg.validator_regex(...)` with `arg.value_parser(|s: &str| regex.is_match(s).then(|| s.to_owned()).ok_or_else(|| ...))` +" ) )] #[cfg(feature = "regex")] @@ -1576,11 +1631,22 @@ impl<'help> Arg<'help> { } /// Deprecated, replaced with [`Arg::value_parser(PossibleValuesParser::new(...))`] + /// + /// Derive: replace `#[clap(possible_value = <1>, possible_value = <2>, ...)]` with `#[clap(value_parser = [<1>, <2>])]`. + /// If the field is not a `String`, instead do `#[clap(value_parser = PossibleValueParser::new([<1>, <2>]).map(T::from_str))]` + /// + /// Builder: replace `arg.possible_value(<1>).possible_value(<2>) with `arg.value_parser([<1>, <2>])` #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "Replaced with `Arg::value_parser(PossibleValuesParser::new(...)).takes_value(true)`" + note = "Replaced with `Arg::value_parser(PossibleValuesParser::new(...)).takes_value(true)` + +Derive: replace `#[clap(possible_value = <1>, possible_value = <2>, ...)]` with `#[clap(value_parser = [<1>, <2>])]`. +If the field is not a `String`, instead do `#[clap(value_parser = PossibleValueParser::new([<1>, <2>]).map(T::from_str))]` + +Builder: replace `arg.possible_value(<1>).possible_value(<2>) with `arg.value_parser([<1>, <2>])` +" ) )] #[must_use] @@ -1593,11 +1659,22 @@ impl<'help> Arg<'help> { } /// Deprecated, replaced with [`Arg::value_parser(PossibleValuesParser::new(...))`] + /// + /// Derive: replace `#[clap(possible_values = [<1>, <2>])]` with `#[clap(value_parser = [<1>, <2>])]`. + /// If the field is not a `String`, instead do `#[clap(value_parser = PossibleValueParser::new([<1>, <2>]).map(T::from_str))]` + /// + /// Builder: replace `arg.possible_values([<1>, <2>) with `arg.value_parser([<1>, <2>])` #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "Replaced with `Arg::value_parser(PossibleValuesParser::new(...)).takes_value(true)`" + note = "Replaced with `Arg::value_parser(PossibleValuesParser::new(...)).takes_value(true)` + +Derive: replace `#[clap(possible_values = [<1>, <2>])]` with `#[clap(value_parser = [<1>, <2>])]`. +If the field is not a `String`, instead do `#[clap(value_parser = PossibleValueParser::new([<1>, <2>]).map(T::from_str))]` + +Builder: replace `arg.possible_values([<1>, <2>) with `arg.value_parser([<1>, <2>])` +" ) )] #[must_use] @@ -1729,15 +1806,29 @@ impl<'help> Arg<'help> { } } - /// Deprecated, replaced with [`Arg::value_parser(...)`] with either [`ValueParser::os_string()`][crate::builder::ValueParser::os_string] - /// or [`ValueParser::path_buf()`][crate::builder::ValueParser::path_buf] + /// Deprecated, replaced with [`value_parser`][Arg::value_parser] + /// + /// Derive: replace `#[clap(allow_invalid_utf8 = true)]` with `#[clap(action)]` (which opts-in to the + /// new clap v4 behavior which gets the type via `value_parser!`) + /// + /// Builder: replace `arg.allow_invalid_utf8(true)` with `arg.value_parser(value_parser!(T))` where + /// `T` is the type of interest, like `OsString` or `PathBuf`, and `matches.value_of_os` with + /// `matches.get_one::` or `matches.values_of_os` with `matches.get_many::` #[inline] #[must_use] #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "Replaced with `Arg::value_parser(...)` with either `ValueParser::os_string()` or `ValueParser::path_buf()`" + note = "Replaced with `value_parser` + +Derive: replace `#[clap(allow_invalid_utf8 = true)]` with `#[clap(action)]` (which opts-in to the +new clap v4 behavior which gets the type via `value_parser!`) + +Builder: replace `arg.allow_invalid_utf8(true)` with `arg.value_parser(value_parser!(T))` where +`T` is the type of interest, like `OsString` or `PathBuf`, and `matches.value_of_os` with +`matches.get_one::` or `matches.values_of_os` with `matches.get_many::` +" ) )] pub fn allow_invalid_utf8(self, yes: bool) -> Self { @@ -1749,13 +1840,22 @@ impl<'help> Arg<'help> { } /// Deprecated, replaced with [`Arg::value_parser(NonEmptyStringValueParser::new())`] + /// + /// Derive: replace `#[clap(forbid_empty_values = true)]` with `#[clap(value_parser = NonEmptyStringValueParser::new())]` + /// + /// Builder: replace `arg.forbid_empty_values(true)` with `arg.value_parser(NonEmptyStringValueParser::new())` #[inline] #[must_use] #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "Replaced with `Arg::value_parser(NonEmptyStringValueParser::new())`" + note = "Replaced with `Arg::value_parser(NonEmptyStringValueParser::new())` + +Derive: replace `#[clap(forbid_empty_values = true)]` with `#[clap(value_parser = NonEmptyStringValueParser::new())]` + +Builder: replace `arg.forbid_empty_values(true)` with `arg.value_parser(NonEmptyStringValueParser::new())` +" ) )] pub fn forbid_empty_values(self, yes: bool) -> Self { @@ -1881,11 +1981,23 @@ impl<'help> Arg<'help> { } /// Deprecated, replaced with [`Arg::use_value_delimiter`] + /// + /// Derive: replace `#[clap(use_delimiter = true)]` with `#[clap(use_value_delimiter = true)]` + /// + /// Builder: replace `arg.use_delimiter(true)` with `arg.use_value_delimiter(true)` #[inline] #[must_use] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Arg::use_value_delimiter`") + deprecated( + since = "3.1.0", + note = "Replaced with `Arg::use_value_delimiter` + +Derive: replace `#[clap(use_delimiter = true)]` with `#[clap(use_value_delimiter = true)]` + +Builder: replace `arg.use_delimiter(true)` with `arg.use_value_delimiter(true)` +" + ) )] pub fn use_delimiter(self, yes: bool) -> Self { self.use_value_delimiter(yes) @@ -2008,11 +2120,23 @@ impl<'help> Arg<'help> { } /// Deprecated, replaced with [`Arg::require_value_delimiter`] + /// + /// Derive: replace `#[clap(require_delimiter = true)]` with `#[clap(require_value_delimiter = true)]` + /// + /// Builder: replace `arg.require_delimiter(true)` with `arg.require_value_delimiter(true)` #[inline] #[must_use] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Arg::require_value_delimiter`") + deprecated( + since = "3.1.0", + note = "Replaced with `Arg::require_value_delimiter` + +Derive: replace `#[clap(require_delimiter = true)]` with `#[clap(require_value_delimiter = true)]` + +Builder: replace `arg.require_delimiter(true)` with `arg.require_value_delimiter(true)` +" + ) )] pub fn require_delimiter(self, yes: bool) -> Self { self.require_value_delimiter(yes) diff --git a/src/builder/arg_group.rs b/src/builder/arg_group.rs index 0fe31710968..76a310ea6b5 100644 --- a/src/builder/arg_group.rs +++ b/src/builder/arg_group.rs @@ -129,9 +129,17 @@ impl<'help> ArgGroup<'help> { } /// Deprecated, replaced with [`ArgGroup::id`] + /// + /// Builder: replaced `group.name(...)` with `group.id(...)` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `ArgGroup::id`") + deprecated( + since = "3.1.0", + note = "Replaced with `ArgGroup::id` + +Builder: replaced `group.name(...)` with `group.id(...)` +" + ) )] pub fn name>(self, n: S) -> Self { self.id(n) diff --git a/src/builder/arg_settings.rs b/src/builder/arg_settings.rs index ecc064caa20..1598d04992a 100644 --- a/src/builder/arg_settings.rs +++ b/src/builder/arg_settings.rs @@ -33,235 +33,463 @@ impl Default for ArgFlags { #[non_exhaustive] pub enum ArgSettings { /// Deprecated, replaced with [`Arg::required`] and [`Arg::is_required_set`] + /// + /// Derive: replace `#[clap(setting = Required)]` with `#[clap(required = true)]` + /// + /// Builder: replace `arg.setting(Required)` with `arg.required(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::required` and `Arg::is_required_set`" + note = "Replaced with `Arg::required` and `Arg::is_required_set` + +Derive: replace `#[clap(setting = Required)]` with `#[clap(required = true)]` + +Builder: replace `arg.setting(Required)` with `arg.required(true)` +" ) )] Required, /// Deprecated, replaced with [`Arg::multiple_values`] and [`Arg::is_multiple_values_set`] + /// + /// Derive: replace `#[clap(setting = MultipleValues)]` with `#[clap(multiple_values = true)]` + /// + /// Builder: replace `arg.setting(MultipleValues)` with `arg.multiple_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::multiple_values` and `Arg::`is_multiple_values_set`" + note = "Replaced with `Arg::multiple_values` and `Arg::`is_multiple_values_set` + +Derive: replace `#[clap(setting = MultipleValues)]` with `#[clap(multiple_values = true)]` + +Builder: replace `arg.setting(MultipleValues)` with `arg.multiple_values(true)` +" ) )] MultipleValues, /// Deprecated, replaced with [`Arg::action`] ([Issue #3772](https://github.com/clap-rs/clap/issues/3772)) #[cfg_attr( feature = "deprecated", - deprecated(since = "3.1.0", note = "Replaced with `Arg::action` (Issue #3772)") + deprecated( + since = "3.1.0", + note = "Replaced with `Arg::action` (Issue #3772) + +Builder: replace `arg.setting(MultipleOccurrences)` with `arg.action(ArgAction::Append)` when taking a value and `arg.action(ArgAction::Count)` with `matches.get_count` when not +" + ) )] MultipleOccurrences, /// Deprecated, see [`ArgSettings::MultipleOccurrences`] (most likely what you want) and /// [`ArgSettings::MultipleValues`] + /// + /// Derive: replace `#[clap(setting = Multiple)]` with `#[clap(multiple_values = true, multiple_occurrences = true)]` + /// + /// Builder: replace `arg.setting(Multiple)` with `arg.multiple_values(true).multiple_occurrences(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Split into `Arg::multiple_occurrences` (most likely what you want) and `Arg::multiple_values`" + note = "Split into `Arg::multiple_occurrences` (most likely what you want) and `Arg::multiple_values` + +Derive: replace `#[clap(setting = Multiple)]` with `#[clap(multiple_values = true, multiple_occurrences = true)]` + +Builder: replace `arg.setting(Multiple)` with `arg.multiple_values(true).multiple_occurrences(true)` +" ) )] #[doc(hidden)] Multiple, /// Deprecated, replaced with [`Arg::value_parser(NonEmptyStringValueParser::new())`] + /// + /// Derive: replace `#[clap(setting = ForbidEmptyValues)]` with `#[clap(value_parser = NonEmptyStringValueParser::new())]` + /// + /// Builder: replace `arg.setting(Multiple)` with `arg.value_parser(NonEmptyStringValueParser::new())` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::value_parser(NonEmptyStringValueParser::new())`" + note = "Replaced with `Arg::value_parser(NonEmptyStringValueParser::new())` + +Derive: replace `#[clap(setting = ForbidEmptyValues)]` with `#[clap(value_parser = NonEmptyStringValueParser::new())]` + +Builder: replace `arg.setting(Multiple)` with `arg.value_parser(NonEmptyStringValueParser::new())` +" ) )] ForbidEmptyValues, /// Deprecated, replaced with [`Arg::global`] and [`Arg::is_global_set`] + /// + /// Derive: replace `#[clap(setting = Global)]` with `#[clap(global = true)]` + /// + /// Builder: replace `arg.setting(Global)` with `arg.global(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::global` and `Arg::is_global_set`" + note = "Replaced with `Arg::global` and `Arg::is_global_set` + +Derive: replace `#[clap(setting = Global)]` with `#[clap(global = true)]` + +Builder: replace `arg.setting(Global)` with `arg.global(true)` +" ) )] Global, /// Deprecated, replaced with [`Arg::hide`] and [`Arg::is_hide_set`] + /// + /// Derive: replace `#[clap(setting = Hidden)]` with `#[clap(hide = true)]` + /// + /// Builder: replace `arg.setting(Hidden)` with `arg.hide(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::hide` and `Arg::is_hide_set`" + note = "Replaced with `Arg::hide` and `Arg::is_hide_set` + +Derive: replace `#[clap(setting = Hidden)]` with `#[clap(hide = true)]` + +Builder: replace `arg.setting(Hidden)` with `arg.hide(true)` +" ) )] Hidden, /// Deprecated, replaced with [`Arg::takes_value`] and [`Arg::is_takes_value_set`] + /// + /// Derive: this setting shouldn't be needed + /// + /// Builder: replace `arg.setting(TakesValue)` with `arg.takes_value(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::takes_value` and `Arg::is_takes_value_set`" + note = "Replaced with `Arg::takes_value` and `Arg::is_takes_value_set` + +Derive: this setting shouldn't be needed + +Builder: replace `arg.setting(TakesValue)` with `arg.takes_value(true)` +" ) )] TakesValue, /// Deprecated, replaced with [`Arg::use_value_delimiter`] and /// [`Arg::is_use_value_delimiter_set`] + /// + /// Derive: replace `#[clap(setting = UseValueDelimiter)]` with `#[clap(use_value_delimiter = true)]` + /// + /// Builder: replace `arg.setting(UseValueDelimiter)` with `arg.use_value_delimiter(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::use_value_delimiter` and `Arg::is_use_value_delimiter_set`" + note = "Replaced with `Arg::use_value_delimiter` and `Arg::is_use_value_delimiter_set` + +Derive: replace `#[clap(setting = UseValueDelimiter)]` with `#[clap(use_value_delimiter = true)]` + +Builder: replace `arg.setting(UseValueDelimiter)` with `arg.use_value_delimiter(true)` +" ) )] UseValueDelimiter, /// Deprecated, replaced with [`Arg::next_line_help`] and [`Arg::is_next_line_help_set`] + /// + /// Derive: replace `#[clap(setting = NextLineHelp)]` with `#[clap(next_line_help = true)]` + /// + /// Builder: replace `arg.setting(NextLineHelp)` with `arg.next_line_help(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::next_line_help` and `Arg::is_next_line_help_set`" + note = "Replaced with `Arg::next_line_help` and `Arg::is_next_line_help_set` + +Derive: replace `#[clap(setting = NextLineHelp)]` with `#[clap(next_line_help = true)]` + +Builder: replace `arg.setting(NextLineHelp)` with `arg.next_line_help(true)` +" ) )] NextLineHelp, /// Deprecated, replaced with [`Arg::require_value_delimiter`] and /// [`Arg::is_require_value_delimiter_set`] + /// + /// Derive: replace `#[clap(setting = RequireDelimiter)]` with `#[clap(require_value_delimiter = true)]` + /// + /// Builder: replace `arg.setting(RequireDelimiter)` with `arg.require_value_delimiter(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::require_value_delimiter` and `Arg::is_require_value_delimiter_set`" + note = "Replaced with `Arg::require_value_delimiter` and `Arg::is_require_value_delimiter_set` + +Derive: replace `#[clap(setting = RequireDelimiter)]` with `#[clap(require_value_delimiter = true)]` + +Builder: replace `arg.setting(RequireDelimiter)` with `arg.require_value_delimiter(true)` +" ) )] RequireDelimiter, /// Deprecated, replaced with [`Arg::hide_possible_values`] and /// [`Arg::is_hide_possible_values_set`] + /// + /// Derive: replace `#[clap(setting = HidePossibleValues)]` with `#[clap(hide_possible_values = true)]` + /// + /// Builder: replace `arg.setting(HidePossibleValues)` with `arg.hide_possible_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::hide_possible_values` and `Arg::is_hide_possible_values_set`" + note = "Replaced with `Arg::hide_possible_values` and `Arg::is_hide_possible_values_set` + +Derive: replace `#[clap(setting = HidePossibleValues)]` with `#[clap(hide_possible_values = true)]` + +Builder: replace `arg.setting(HidePossibleValues)` with `arg.hide_possible_values(true)` +" ) )] HidePossibleValues, /// Deprecated, replaced with [`Arg::allow_hyphen_values`] and /// [`Arg::is_allow_hyphen_values_set`] + /// + /// Derive: replace `#[clap(setting = AllowHyphenValues)]` with `#[clap(allow_hyphen_values = true)]` + /// + /// Builder: replace `arg.setting(AllowHyphenValues)` with `arg.allow_hyphen_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set`" + note = "Replaced with `Arg::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set` + +Derive: replace `#[clap(setting = AllowHyphenValues)]` with `#[clap(allow_hyphen_values = true)]` + +Builder: replace `arg.setting(AllowHyphenValues)` with `arg.allow_hyphen_values(true)` +" ) )] AllowHyphenValues, /// Deprecated, replaced with [`Arg::allow_hyphen_values`] and /// [`Arg::is_allow_hyphen_values_set`] + /// + /// Derive: replace `#[clap(setting = AllowLeadingHyphen)]` with `#[clap(allow_hyphen_values = true)]` + /// + /// Builder: replace `arg.setting(AllowLeadingHyphen)` with `arg.allow_hyphen_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `Arg::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set`" + note = "Replaced with `Arg::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set` + +Derive: replace `#[clap(setting = AllowLeadingHyphen)]` with `#[clap(allow_hyphen_values = true)]` + +Builder: replace `arg.setting(AllowLeadingHyphen)` with `arg.allow_hyphen_values(true)` +" ) )] #[doc(hidden)] AllowLeadingHyphen, /// Deprecated, replaced with [`Arg::require_equals`] and [`Arg::is_require_equals_set`] + /// + /// Derive: replace `#[clap(setting = RequireEquals)]` with `#[clap(require_equals = true)]` + /// + /// Builder: replace `arg.setting(RequireEquals)` with `arg.require_equals(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::require_equals` and `Arg::is_require_equals_set`" + note = "Replaced with `Arg::require_equals` and `Arg::is_require_equals_set` + +Derive: replace `#[clap(setting = RequireEquals)]` with `#[clap(require_equals = true)]` + +Builder: replace `arg.setting(RequireEquals)` with `arg.require_equals(true)` +" ) )] RequireEquals, /// Deprecated, replaced with [`Arg::last`] and [`Arg::is_last_set`] + /// + /// Derive: replace `#[clap(setting = Last)]` with `#[clap(last = true)]` + /// + /// Builder: replace `arg.setting(Last)` with `arg.last(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::last` and `Arg::is_last_set`" + note = "Replaced with `Arg::last` and `Arg::is_last_set` + +Derive: replace `#[clap(setting = Last)]` with `#[clap(last = true)]` + +Builder: replace `arg.setting(Last)` with `arg.last(true)` +" ) )] Last, /// Deprecated, replaced with [`Arg::hide_default_value`] and [`Arg::is_hide_default_value_set`] + /// + /// Derive: replace `#[clap(setting = HideDefaultValue)]` with `#[clap(hide_default_value = true)]` + /// + /// Builder: replace `arg.setting(HideDefaultValue)` with `arg.hide_default_value(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::hide_default_value` and `Arg::is_hide_default_value_set`" + note = "Replaced with `Arg::hide_default_value` and `Arg::is_hide_default_value_set` + +Derive: replace `#[clap(setting = HideDefaultValue)]` with `#[clap(hide_default_value = true)]` + +Builder: replace `arg.setting(HideDefaultValue)` with `arg.hide_default_value(true)` +" ) )] HideDefaultValue, /// Deprecated, replaced with [`Arg::ignore_case`] and [`Arg::is_ignore_case_set`] + /// + /// Derive: replace `#[clap(setting = IgnoreCase)]` with `#[clap(ignore_case = true)]` + /// + /// Builder: replace `arg.setting(IgnoreCase)` with `arg.ignore_case(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::ignore_case` and `Arg::is_ignore_case_set`" + note = "Replaced with `Arg::ignore_case` and `Arg::is_ignore_case_set` + +Derive: replace `#[clap(setting = IgnoreCase)]` with `#[clap(ignore_case = true)]` + +Builder: replace `arg.setting(IgnoreCase)` with `arg.ignore_case(true)` +" ) )] IgnoreCase, /// Deprecated, replaced with [`Arg::ignore_case`] and [`Arg::is_ignore_case_set`] + /// + /// Derive: replace `#[clap(setting = CaseInsensitive)]` with `#[clap(ignore_case = true)]` + /// + /// Builder: replace `arg.setting(CaseInsensitive)` with `arg.ignore_case(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `Arg::ignore_case` and `Arg::is_ignore_case_set`" + note = "Replaced with `Arg::ignore_case` and `Arg::is_ignore_case_set` + +Derive: replace `#[clap(setting = CaseInsensitive)]` with `#[clap(ignore_case = true)]` + +Builder: replace `arg.setting(CaseInsensitive)` with `arg.ignore_case(true)` +" ) )] #[doc(hidden)] CaseInsensitive, /// Deprecated, replaced with [`Arg::hide_env`] and [`Arg::is_hide_env_set`] + /// + /// Derive: replace `#[clap(setting = HideEnv)]` with `#[clap(hide_env = true)]` + /// + /// Builder: replace `arg.setting(HideEnv)` with `arg.hide_env(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::hide_env` and `Arg::is_hide_env_set`" + note = "Replaced with `Arg::hide_env` and `Arg::is_hide_env_set` + +Derive: replace `#[clap(setting = HideEnv)]` with `#[clap(hide_env = true)]` + +Builder: replace `arg.setting(HideEnv)` with `arg.hide_env(true)` +" ) )] #[cfg(feature = "env")] HideEnv, /// Deprecated, replaced with [`Arg::hide_env_values`] and [`Arg::is_hide_env_values_set`] + /// + /// Derive: replace `#[clap(setting = HideEnvValues)]` with `#[clap(hide_env_values = true)]` + /// + /// Builder: replace `arg.setting(HideEnvValues)` with `arg.hide_env_values(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::hide_env_values` and `Arg::is_hide_env_values_set`" + note = "Replaced with `Arg::hide_env_values` and `Arg::is_hide_env_values_set` + +Derive: replace `#[clap(setting = HideEnvValues)]` with `#[clap(hide_env_values = true)]` + +Builder: replace `arg.setting(HideEnvValues)` with `arg.hide_env_values(true)` +" ) )] #[cfg(feature = "env")] HideEnvValues, /// Deprecated, replaced with [`Arg::hide_short_help`] and [`Arg::is_hide_short_help_set`] + /// + /// Derive: replace `#[clap(setting = HiddenShortHelp)]` with `#[clap(hide_short_help = true)]` + /// + /// Builder: replace `arg.setting(HiddenShortHelp)` with `arg.hide_short_help(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::hide_short_help` and `Arg::is_hide_short_help_set`" + note = "Replaced with `Arg::hide_short_help` and `Arg::is_hide_short_help_set` + +Derive: replace `#[clap(setting = HiddenShortHelp)]` with `#[clap(hide_short_help = true)]` + +Builder: replace `arg.setting(HiddenShortHelp)` with `arg.hide_short_help(true)` +" ) )] HiddenShortHelp, /// Deprecated, replaced with [`Arg::hide_long_help`] and [`Arg::is_hide_long_help_set`] + /// + /// Derive: replace `#[clap(setting = HiddenLongHelp)]` with `#[clap(hide_long_help = true)]` + /// + /// Builder: replace `arg.setting(HiddenLongHelp)` with `arg.hide_long_help(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::hide_long_help` and `Arg::is_hide_long_help_set`" + note = "Replaced with `Arg::hide_long_help` and `Arg::is_hide_long_help_set` + +Derive: replace `#[clap(setting = HiddenLongHelp)]` with `#[clap(hide_long_help = true)]` + +Builder: replace `arg.setting(HiddenLongHelp)` with `arg.hide_long_help(true)` +" ) )] HiddenLongHelp, - /// Deprecated, replaced with [`Arg::allow_invalid_utf8`] and [`Arg::is_allow_invalid_utf8_set`] + /// Deprecated, replaced with [`Arg::value_parser`] + /// + /// Derive: replace `#[clap(setting = AllowInvalidUtf8)]` with `#[clap(action)]` (which opts-in to the + /// new clap v4 behavior which gets the type via `value_parser!`) + /// + /// Builder: replace `arg.setting(AllowInvalidUtf8)` with `arg.value_parser(value_parser!(T))` where + /// `T` is the type of interest, like `OsString` or `PathBuf`, and `matches.value_of_os` with + /// `matches.get_one::` or `matches.values_of_os` with `matches.get_many::` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::allow_invalid_utf8` and `Arg::is_allow_invalid_utf8_set`" + note = "Replaced with `value_parser` + +Derive: replace `#[clap(setting = AllowInvalidUtf8)]` with `#[clap(action)]` (which opts-in to the +new clap v4 behavior which gets the type via `value_parser!`) + +Builder: replace `arg.setting(AllowInvalidUtf8)` with `arg.value_parser(value_parser!(T))` where +`T` is the type of interest, like `OsString` or `PathBuf`, and `matches.value_of_os` with +`matches.get_one::` or `matches.values_of_os` with `matches.get_many::` +" ) )] AllowInvalidUtf8, /// Deprecated, replaced with [`Arg::exclusive`] and [`Arg::is_exclusive_set`] + /// + /// Derive: replace `#[clap(setting = Exclusive)]` with `#[clap(exclusive = true)]` + /// + /// Builder: replace `arg.setting(Exclusive)` with `arg.exclusive(true)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::exclusive` and `Arg::is_exclusive_set`" + note = "Replaced with `Arg::exclusive` and `Arg::is_exclusive_set` + +Derive: replace `#[clap(setting = Exclusive)]` with `#[clap(exclusive = true)]` + +Builder: replace `arg.setting(Exclusive)` with `arg.exclusive(true)` +" ) )] Exclusive, diff --git a/src/builder/command.rs b/src/builder/command.rs index de59ad8cd95..3194bb01aa9 100644 --- a/src/builder/command.rs +++ b/src/builder/command.rs @@ -959,9 +959,21 @@ impl<'help> App<'help> { } /// Deprecated, replaced with [`ArgAction::Set`][super::ArgAction::Set] + /// + /// The new actions (`ArgAction::Set`, `ArgAction::SetTrue`) do this by default. + /// + /// See `ArgAction::StoreValue` and `ArgAction::IncOccurrence` for how to migrate #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `Arg::action(ArgAction::Set)`") + deprecated( + since = "3.2.0", + note = "Replaced with `Arg::action(ArgAction::...)` + +The new actions (`ArgAction::Set`, `ArgAction::SetTrue`) do this by default. + +See `ArgAction::StoreValue` and `ArgAction::IncOccurrence` for how to migrate +" + ) )] pub fn args_override_self(self, yes: bool) -> Self { if yes { diff --git a/src/parser/matches/arg_matches.rs b/src/parser/matches/arg_matches.rs index 2585c02199f..753443e4e52 100644 --- a/src/parser/matches/arg_matches.rs +++ b/src/parser/matches/arg_matches.rs @@ -405,9 +405,17 @@ impl ArgMatches { } /// Deprecated, replaced with [`ArgMatches::get_one()`] + /// + /// Replace `m.value_of(...)` with `m.get_one::(...).map(|s| s.as_str())` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `ArgMatches::get_one()`") + deprecated( + since = "3.2.0", + note = "Replaced with `ArgMatches::get_one()` + +Replace `m.value_of(...)` with `m.get_one::(...).map(|s| s.as_str())` +" + ) )] #[cfg_attr(debug_assertions, track_caller)] pub fn value_of(&self, id: T) -> Option<&str> { @@ -418,9 +426,17 @@ impl ArgMatches { } /// Deprecated, replaced with [`ArgMatches::get_one()`] + /// + /// Replace `m.value_of(...)` with `m.get_one::(...).map(|s| s.as_str())` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `ArgMatches::get_one()`") + deprecated( + since = "3.2.0", + note = "Replaced with `ArgMatches::get_one()` + +Replace `m.value_of(...)` with `m.get_one::(...).map(|s| s.as_str())` +" + ) )] #[cfg_attr(debug_assertions, track_caller)] pub fn value_of_lossy(&self, id: T) -> Option> { @@ -431,9 +447,17 @@ impl ArgMatches { } /// Deprecated, replaced with [`ArgMatches::get_one()`] + /// + /// Replace `m.value_of(...)` with `m.get_one::(...).map(|s| s.as_os_str())` #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `ArgMatches::get_one()`") + deprecated( + since = "3.2.0", + note = "Replaced with `ArgMatches::get_one()` + +Replace `m.value_of(...)` with `m.get_one::(...).map(|s| s.as_os_str())` +" + ) )] #[cfg_attr(debug_assertions, track_caller)] pub fn value_of_os(&self, id: T) -> Option<&OsStr> { @@ -446,7 +470,11 @@ impl ArgMatches { /// Deprecated, replaced with [`ArgMatches::get_many()`] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `ArgMatches::get_many()`") + deprecated( + since = "3.2.0", + note = "Replaced with `ArgMatches::get_many()` +" + ) )] #[cfg_attr(debug_assertions, track_caller)] pub fn values_of(&self, id: T) -> Option { @@ -620,11 +648,30 @@ impl ArgMatches { /// Deprecated, replaced with [`ArgAction::SetTrue`][crate::ArgAction] or /// [`ArgMatches::contains_id`]. + /// + /// With `ArgAction::SetTrue` becoming the new flag default in clap v4, flags will always be present. + /// To make the migration easier, we've renamed this function so people can identify when they actually + /// care about an arg being present or if they need to update to the new way to check a flag's + /// presence. + /// + /// For flags, call `arg.action(ArgAction::SetTrue)` and lookup the value with `matches.get_flag(...)` + /// + /// For presence, replace `matches.is_present(...)` with `matches.contains_id(...)` #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "Replaced with either `ArgAction::SetTrue` or `ArgMatches::contains_id(...)`" + note = "Replaced with either `ArgAction::SetTrue` or `ArgMatches::contains_id(...)` to avoid confusion over new semantics + +With `ArgAction::SetTrue` becoming the new flag default in clap v4, flags will always be present. +To make the migration easier, we've renamed this function so people can identify when they actually +care about an arg being present or if they need to update to the new way to check a flag's +presence. + +For flags, call `arg.action(ArgAction::SetTrue)` and lookup the value with `matches.get_flag(...)` + +For presence, replace `matches.is_present(...)` with `matches.contains_id(...)` +" ) )] #[cfg_attr(debug_assertions, track_caller)] @@ -669,11 +716,28 @@ impl ArgMatches { /// Deprecated, replaced with [`ArgAction::Count`][crate::ArgAction], /// [`ArgMatches::get_many`]`.len()`, or [`ArgMatches::value_source`]. + /// + /// `occurrences_of`s meaning was overloaded and we are replacing it with more direct approaches. + /// + /// For counting flags, call `arg.action(ArgAction::Count)` and lookup the value with `matches.get_count(...)` + /// + /// To check if a user explicitly passed in a value, check the source with `matches.value_source(...)` + /// + /// To see how many values there are, call `matches.get_many::(...).map(|v| v.len())` #[cfg_attr( feature = "deprecated", deprecated( since = "3.2.0", - note = "Replaced with either `ArgAction::Count`, `ArgMatches::get_many(...).len()`, or `ArgMatches::value_source`" + note = "Replaced with either `ArgAction::Count`, `ArgMatches::get_many(...).len()`, or `ArgMatches::value_source` + +`occurrences_of`s meaning was overloaded and we are replacing it with more direct approaches. + +For counting flags, call `arg.action(ArgAction::Count)` and lookup the value with `matches.get_count(...)` + +To check if a user explicitly passed in a value, check the source with `matches.value_source(...)` + +To see how many values there are, call `matches.get_many::(...).map(|v| v.len())` +" ) )] #[cfg_attr(debug_assertions, track_caller)] @@ -914,7 +978,27 @@ impl ArgMatches { #[doc(hidden)] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.2.0", note = "Replaced with `ArgMatches::try_get_one()`") + deprecated( + since = "3.2.0", + note = "Replaced with `ArgMatches::try_get_one()` + +When helping to catch mistyped argument IDs, we overlooked the use cases for more dynamic lookups +of arguments, so we added `is_valid_arg` as a short-term hack. Since then, we've generalized +`value_of` as `try_get_one` to give callers all the relevant information they need. + +So replace +``` +if matches.is_valid_arg(...) { + matches.value_of(...) +} +``` +with +``` +if let Ok(value) = matches.try_get_one::(...) { +} +``` +" + ) )] pub fn is_valid_arg(&self, _id: impl Key) -> bool { #[cfg(debug_assertions)]