unstale

cargo / clap

clap

What changed in clap 3 to 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-25.

82 breaking11 deprecations48 new APIs and options6 behavior and defaults15 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

clap 471 changes

Breaking changes 30

  • Fixes precedence between positionals using value_terminator("--") and escapes, so ./foo -- bar treats the first argument as empty rather than escaping future arguments.

    4.5.55release notes

  • Its default value type changed from String to OsString.

    4.0.0release notes

  • Short flags now take precedence over hyphen values when this argument setting is used.

    4.0.0release notes

  • Applies per occurrence rather than when a value is missing across all occurrences.

    4.0.0release notes

  • The derive attribute was removed in favor of value_enum.

    4.0.0release notes

  • Use Arg::num_args(1..=M) to set a maximum per occurrence.

    4.0.0release notes

  • Use Arg::num_args(N..) to set a minimum per occurrence.

    4.0.0release notes

  • Use Arg::num_args with a range instead.

    4.0.0release notes

  • Replaces several value-count APIs and controls the number of raw command-line arguments captured per occurrence; it accepts single values and ranges.

    4.0.0release notes

  • Removed; use Arg::value_delimiter or implement a custom parser with TypedValueParser.

    4.0.0release notes

  • Use Arg::num_args(1) or Arg::num_args(0) instead.

    4.0.0release notes

  • Use this derive attribute in place of the removed arg_enum attribute.

    4.0.0release notes

  • Derives now default to value_parser instead of parse; parse support was removed.

    4.0.0release notes

  • The terminator must now be its own command-line argument rather than appearing in a delimited list.

    4.0.0release notes

  • The macro now assigns an action based on argument form; use the corresponding ArgMatches getter for the resulting action.

    4.0.0release notes

  • An argument's default action is now ArgAction::Set rather than ArgAction::IncOccurrence.

    4.0.0release notes

  • Use this instead of ArgMatches::occurrences_of for arguments whose action is ArgAction::Count.

    4.0.0release notes

  • Use this instead of ArgMatches::is_present for flags whose action is ArgAction::SetTrue.

    4.0.0release notes

  • Use this instead of ArgMatches::values_of for arguments whose action is ArgAction::Append.

    4.0.0release notes

  • Use this instead of ArgMatches::value_of for arguments whose action is ArgAction::Set.

    4.0.0release notes

  • Set this to true to allow self-overrides for ArgAction::Set, ArgAction::SetTrue, and ArgAction::SetFalse, which now conflict by default.

    4.0.0release notes

  • Lifetimes were removed from Command, Arg, ArgGroup, and PossibleValue, assuming 'static unless the string feature is enabled.

    4.0.0release notes

  • Now returns a StyledStr.

    4.0.0release notes

  • Replaced with ErrorKind::InvalidValue.

    4.0.0release notes

  • Replaces ErrorKind::UnrecognizedSubcommand.

    4.0.0release notes

  • Replaced with ErrorKind::InvalidSubcommand.

    4.0.0release notes

  • Moved into the error module.

    4.0.0release notes

  • The minimum supported Rust version is now 1.60.0.

    4.0.0release notes

  • Replaces various one-off value-validation forms and allows derives to handle PathBuf, including invalid UTF-8.

    4.0.0release notes

  • Help line wrapping is behind this feature flag; enable it or hard-code line wraps.

    4.0.0release notes

Deprecations 8

  • Deprecated in favor of Arg::env.

    4.0.0release notes

  • Deprecated in favor of Arg::num_args, whose per-occurrence semantics differ from the old API.

    4.0.0release notes

  • Deprecated in favor of Arg::value_delimiter.

    4.0.0release notes

  • Deprecated in favor of Arg::allow_hyphen_values.

    4.0.0release notes

  • Deprecated in favor of Arg::allow_negative_numbers.

    4.0.0release notes

  • Deprecated in favor of Arg::trailing_var_arg.

    4.0.0release notes

  • Deprecated in favor of Command::render_help.

    4.0.0release notes

  • Deprecated in favor of Command::render_long_help.

    4.0.0release notes

New APIs and options 17

  • Adds the defer attribute to opt in to lazy initialisation of subcommands.

    4.6.7release notes

  • Adds the get_overridden_usage method to Command.

    4.6.6release notes

  • Adds default_values_if for conditionally setting default values.

    4.5.53release notes

  • Adds default_values_ifs for conditionally setting default values.

    4.5.53release notes

  • Iterates over the arguments and groups found when parsing.

    4.0.0release notes

  • Use this to disable the built-in help flag when providing a custom one.

    4.0.0release notes

  • Use this to disable the built-in version flag when providing a custom one.

    4.0.0release notes

  • Supports the new {tab} variable.

    4.0.0release notes

  • Formats help into a StyledStr.

    4.0.0release notes

  • Formats long help into a StyledStr.

    4.0.0release notes

  • Changes the formatter for dropping binary size.

    4.0.0release notes

  • Formats an error into a StyledStr.

    4.0.0release notes

  • A new default feature flag that can be turned off for smaller binaries.

    4.0.0release notes

  • A string newtype used for argument IDs, distinguishing opaque IDs from user-visible strings.

    4.0.0release notes

  • Enables support for Strings and runtime-generated data without managing lifetimes.

    4.0.0release notes

  • Displays a StyledStr with ANSI escape codes.

    4.0.0release notes

  • Now implements conversions from OsStr, OsString, str, and String.

    4.0.0release notes

Behavior and default changes 3

  • Accept Cow where String and &str are accepted, allowing callers to use a copy-on-write string type.

    4.5.50release notes

  • Builder API users should explicitly set an action for each argument; options use StoreValue and flags use IncOccurrences.

    4.0.0release notes

  • Help output is denser, uses title-case headings and lists commands before arguments; the name, version, and author are omitted by default.

    4.0.0release notes

Fixes and other changes 13

  • Help output now correctly marks which value_names are optional according to num_args.

    4.6.5release notes

  • The derive macro now allows "literal".function() as an attribute value.

    4.6.3release notes

  • Help output says “alias” when there is only one.

    4.6.2release notes

  • Rebuilds now happen when a read environment variable changes.

    4.6.1release notes

  • Empty default values and possible values are now quoted in help output.

    4.5.60release notes

  • Command::ignore_errors no longer masks help or version on subcommands.

    4.5.59release notes

  • Fixed problems with an argument using value_terminator("--") when another argument uses last(true).

    4.5.57release notes

  • Conflicting arguments are no longer shown in the usage on conflict errors.

    4.5.56release notes

  • When PossibleValue::help is present, [default] appears in its own paragraph in --help output.

    4.5.54release notes

  • Avoids panicking when args_conflicts_with_subcommands conflicts with an ArgGroup.

    4.5.52release notes

  • Help output no longer panics on short flags using ArgAction::Count.

    4.5.51release notes

  • Help output now correctly calculates padding for short flags that take a value.

    4.5.51release notes

  • The help title and version output now use Command::display_name rather than Command::bin_name.

    4.0.0release notes

clap 391 changes

Breaking changes 52

  • Provides the replacement for ArgMatches::usage.

    3.0.0release notes

  • No longer implies a leading tab, allowing multi lined usages.

    3.0.0release notes

  • Now returns std::io::Result.

    3.0.0release notes

  • Removed; use app_from_crate instead.

    3.0.0release notes

  • Some App methods, including this one, now take mutable self instead of shared self; it also returns std::io::Result.

    3.0.0release notes

  • Removed.

    3.0.0release notes

  • Opts out of the new default colored-help behavior.

    3.0.0release notes

  • Enables debug assertions that detect missing help descriptions.

    3.0.0release notes

  • Removed because propagating global values down is now the default.

    3.0.0release notes

  • Strict UTF-8 behavior is now the default and asserts unless the documented invalid-UTF-8 settings and OS-value accessor are used together.

    3.0.0release notes

  • Unified help grouping is now the default; {flags} and {unified} assert if present in App::help_template.

    3.0.0release notes

  • No longer implies ArgSettings::TakesValue.

    3.0.0release notes

  • Replaced by the more specific Arg::multiple_values and Arg::multiple_occurrences APIs.

    3.0.0release notes

  • Specifies that an argument can occur multiple times.

    3.0.0release notes

  • Specifies that an argument accepts multiple values.

    3.0.0release notes

  • No longer implies ArgSettings::TakesValue or ArgSettings::UseValueDelimiter.

    3.0.0release notes

  • No longer implies ArgSettings::ForbidEmptyValues.

    3.0.0release notes

  • Sets settings using Arg::setting(Setting1 | Setting2).

    3.0.0release notes

  • Replaced with Arg::setting using a setting expression.

    3.0.0release notes

  • Now takes a char instead of a string slice.

    3.0.0release notes

  • Now accepts a string-slice input and a result with a displayable error type.

    3.0.0release notes

  • Now accepts a result with an OS-string error instead of requiring a unit success value.

    3.0.0release notes

  • Now sets the value name rather than appending it.

    3.0.0release notes

  • The BTreeMap conversion was replaced with conversion from YAML.

    3.0.0release notes

  • Panics on unknown arguments.

    3.0.0release notes

  • No longer checks subcommand names.

    3.0.0release notes

  • Now returns Option<(&str, &ArgMatches)>.

    3.0.0release notes

  • Replaced with App::generate_usage.

    3.0.0release notes

  • Removed in favor of ArgSettings::ForbidEmptyValues.

    3.0.0release notes

  • Crate information support is gated behind the cargo feature flag.

    3.0.0release notes

  • Completion generation has been split out into a separate crate.

    3.0.0release notes

  • Integrates the StructOpt derive approach through clap::Parser; requires the derive feature.

    3.0.0release notes

  • The derive attribute is replaced by default_value_t.

    3.0.0release notes

  • Replaces the derive attribute default_value.

    3.0.0release notes

  • Environment-variable support is gated behind the env feature flag.

    3.0.0release notes

  • Environment support is a non-default feature for faster builds and smaller binaries.

    3.0.0release notes

  • Some environment-variable values are now treated as false for flags, not only as absent.

    3.0.0release notes

  • Now has type Vec<String> instead of Option<Vec<String>>.

    3.0.0release notes

  • Made private; use Error::to_string.

    3.0.0release notes

  • Marked non-exhaustive.

    3.0.0release notes

  • New name for ErrorKind::MissingArgumentOrSubcommand.

    3.0.0release notes

  • Renamed to ErrorKind::DisplayHelp.

    3.0.0release notes

  • Renamed to ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand.

    3.0.0release notes

  • Renamed to ErrorKind::DisplayVersion.

    3.0.0release notes

  • Default help text wrapping is limited to 100 when the wrap_help feature is disabled.

    3.0.0release notes

  • The minimum required Rust compiler version is 1.54.0.

    3.0.0release notes

  • When using no-default-features, enable the std feature.

    3.0.0release notes

  • By default, the App is no longer initialized with crate information; opt in with the author, about, or version attributes.

    3.0.0release notes

  • Nested subcommands now require a #[clap(subcommand)] attribute.

    3.0.0release notes

  • Unicode support is a non-default feature, enabling faster builds and smaller binaries for ASCII-only CLIs.

    3.0.0release notes

  • Marked non-exhaustive.

    3.0.0release notes

  • Vec<_> and Option<Vec<_>> now use multiple_occurrences rather than multiple.

    3.0.0release notes

Deprecations 3

  • Deprecated in favor of arg!.

    3.0.0release notes

  • Deprecated in favor of the builder API with arg!.

    3.0.0release notes

  • The YAML API is deprecated in favor of the builder or derive APIs.

    3.0.0release notes

New APIs and options 31

  • Specifies the app's color setting.

    3.0.0release notes

  • Provides a test helper for debug assertions.

    3.0.0release notes

  • Supports custom error reporting.

    3.0.0release notes

  • Sets a custom help heading for future arguments.

    3.0.0release notes

  • Changes an existing argument, particularly useful for help and version arguments.

    3.0.0release notes

  • Experimental API for aliasing an argument to a group of arguments, behind the unstable-replace feature.

    3.0.0release notes

  • Sets a custom help heading for subcommands.

    3.0.0release notes

  • Sets the value name for subcommands.

    3.0.0release notes

  • Enables partial parsing.

    3.0.0release notes

  • Allows long argument abbreviations, like subcommand abbreviations.

    3.0.0release notes

  • Experimental BusyBox-like multi-call support, behind the unstable-multicall feature.

    3.0.0release notes

  • Disables built-in help behavior.

    3.0.0release notes

  • Disables built-in version behavior.

    3.0.0release notes

  • Detects subcommands among positional arguments.

    3.0.0release notes

  • Makes cmd help print long help (--help instead of -h).

    3.0.0release notes

  • Creates an Arg from a compile-time usage parser.

    3.0.0release notes

  • Adds extra context after the long help message.

    3.0.0release notes

  • Adds extra context before the long help message.

    3.0.0release notes

  • Provides a default value when an option is present without a value, for cases such as --color[=<WHEN>].

    3.0.0release notes

  • Supports conditional default values.

    3.0.0release notes

  • Adds a derive attribute for integrating with the ArgEnum trait.

    3.0.0release notes

  • Allows an argument to conflict with all other arguments.

    3.0.0release notes

  • Sets a custom help heading for the current argument.

    3.0.0release notes

  • Provides hints to completion scripts.

    3.0.0release notes

  • Experimental support for grouping multiple values within multiple occurrences, behind the unstable-grouped feature.

    3.0.0release notes

  • Deriving ArgEnum generates possible values for arguments; requires the derive feature.

    3.0.0release notes

  • Adds derive support for defaulting with native types.

    3.0.0release notes

  • Adds support for flag subcommands.

    3.0.0release notes

  • Enables argument validation with a regex.

    3.0.0release notes

  • Short flags can have aliases.

    3.0.0release notes

  • Adds a new update API.

    3.0.0release notes

Behavior and default changes 3

  • Version flags are generated only when App::version or App::long_version is set.

    3.0.0release notes

  • Colored help is now enabled by default and can be opted out with AppSettings::DisableColoredHelp.

    3.0.0release notes

  • Now Unicode-aware when the unicode feature is enabled.

    3.0.0release notes

Fixes and other changes 2

  • An empty authors field in Cargo.toml is handled gracefully by app_from_crate.

    3.0.0release notes

  • Now always respected, even when that means colors are skipped in some cases.

    3.0.0release notes