NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #781 most downloaded on crates.io
Generate shell completion scripts for your clap::Command
Last release 17 days ago
15 Sep 2026
Ships fairly regularly
a new release about every 4 weeks
Nearly every release is documented
notes for 59 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
5 years old
134 releases · first in 2021
One column per quarter.
### Internal - Update dependencies
dynamic to engine*(builder)* Expose Arg::get_display_order and Command::get_display_order
Arg::get_display_order and Command::get_display_order*(help)* Style required argument groups
command and env out of dynamicArgValueCompleter precedence over ValueEnumcommand and env out of dynamicaot module*(derive)* Improve error messages when derive feature is missing
derive feature is missing*(unstable-ext)* Arg::remove changed return types
Arg::remove changed return typesArg::remove return the removed itemdynamic::shells to dynamic::commanddynamic::command with unstable-command featureenv::CompleteEnv application integration*(unstable-ext)* Added Arg::add for attaching arbitrary state, like completion hints, to Arg without Arg knowing about it
Arg::add for attaching arbitrary state, like completion hints, to Arg without Arg knowing about itCustomCompleter::completions to CustomCompleter::candidatesCompleter to shells::ShellCompletershells::CompleteArgs::complete--register optional--shell optionalshells::CompleteArgs and shells::CompleteCommand at top-level*(derive)* Improve error message when #[flatten]ing an optional #[group(skip)]
#[flatten]ing an optional #[group(skip)]ArgValueCompleter for custom completionsCompletionCandidate::visible was renamed to CompletionCandidate::hide*(dynamic)* Support completing with num_args
num_args*(dynamic)* Add support for -fbar and -f=bar completions
-fbar and -f=bar completionsNothing published for this version
*(error)* When defining a custom help flag, be sure to suggest it like we do the built-in one
--option val[TAB]### Fixes - Reduce extra flushes
Clean up error message when too few arguments for num_args
num_argsNothing published for this version
Allow exclusive to override required_unless_present, required_unless_present_any, required_unless_present_all
exclusive to override required_unless_present, required_unless_present_any, required_unless_present_all*(derive)* Allow non-literal #[arg(id)] attributes again
#[arg(id)] attributes again### Internal - *(derive)* Update heck
heck### Fixes - *(macros)* Silence a warning
*(error)* Include suggestion to add -- even if there is a "did you mean" so long as last or trailing_var_arg is used
-- even if there is a "did you mean" so long as last or trailing_var_arg is used### Compatibility - Update MSRV to 1.74
Cross link derive's attribute reference to derive tutorial
*(help)* Show correct Command::about under flattened headings
Command::about under flattened headingshide when flattening subcommandsValueHint::FilePathValueHint::DirPathValueHint::OtherAdd Command::flatten_help to allow git stash -h like help for subcommands
Command::flatten_help to allow git stash -h like help for subcommands### Performance - Reduced code size
### Internal - Upgrade anstream
anstream*(parser)* When inferring subcommand name or long_flag, allow ambiguous-looking matches that unambiguously map back to the same command
name or long_flag, allow ambiguous-looking matches that unambiguously map back to the same commandlong_flag, don't panic### Internal - Update terminal_size to 0.3
terminal_size to 0.3*(derive)* Clarify use of attributes within the tutorial
Improve build times by removing once_cell dependency
once_cell dependency### Features - Stabilize Command::styles
Command::styles### compatibility - update msrv to 1.70.0
-*(derive)* Don't produce unused_equalifications warnings when someone brings a clap type into scope
unused_equalifications warnings when someone brings a clap type into scope*(derive)* Reduce the amount of generated code
*(assert)* Allow multiple, value-terminated, positional arguments
last assertionvalue_terminator has higher precedence than allow_hyphen_values--helpCommand::styles for theming help/errors (behind unstable-styles)
Command::styles for theming help/errors (behind unstable-styles)### Internal - Update dependencies
Don't highlight uninteresting parts of the error message
Removed the languishing unstable-replace feature (open to discussion at #2836)
unstable-replace feature (open to discussion at #2836)unstable-grouped featureStyledStr to accept text styled with ANSI escape codesCLICOLOR, CLICOLOR_FORCE*(help)* Don't show long help for --help just because hidden possible values include a description
--help just because hidden possible values include a description*(help)* Don't show long help for --help just because a hidden arg has a possible value with a description
--help just because a hidden arg has a possible value with a description*(help)* Respect disable_colored_help when using arg_required_else_help
disable_colored_help when using arg_required_else_helparg! macro*(error)* Improve suggested flag/value/subcommand when two share a long preifx
subcommands, rather than subcommandIn documentation, refer to get_flag, rather than get_one::
get_flag, rather than get_one::<bool>*(error)* Small softening attempt for "unexpected argument" error
For apps with custom --help and --version flags:
MSRV changed to 1.64.0
For apps with custom --help and --version flags:
--help and --version changedWhen apps have errors imitating clap's error style:
ArgMatches::get_occurrences support for argument values to be grouped by their occurrenceupgrade_from when arguments / subcommands are explicitly marked as required--help and --version (also helps with overflow)*(derive)* Populate implicit ArgGroup
#[group(skip)] on Parser derive*(derive)* Support #[group(skip)] (#4279, #4301)
#[group(skip)] (#4279, #4301)### Features - Added Shell::from_env
Shell::from_env*(error)* Specialize the self-conflict error to look like clap v3
*(error)* Quote literals consistently
--) suggestions*(parser)* SetFalse should conflict with itself like SetTrue and Set
SetFalse should conflict with itself like SetTrue and Setgit diff git <TAB> completionsgit diff log <TAB> completions*(derive)* Ensure #[clap(...)] attribute still works
#[clap(...)] attribute still worksResolve behavior changes (see "subtle changes" under BREAKING CHANGES)
Arg::num_args(range)
Clap has had several ways for controlling how many values will be captured without always being clear on how they interacted, including
Arg::multiple_values(true)Arg::number_of_values(4)Arg::min_values(2)Arg::max_values(20)Arg::takes_value(true)These have now all been collapsed into Arg::num_args which accepts both
single values and ranges of values. num_args controls how many raw arguments
on the command line will be captured as values per occurrence and independent
of value delimiters.
See Issue 2688 for more background.
Polishing Help
Clap strives to give a polished CLI experience out of the box with little
ceremony. With some feedback that has accumulated over time, we took this
release as an opportunity to re-evaluate our --help output to make sure it is
meeting that goal.
In doing this evaluation, we wanted to keep in mind:
Before:
git
A fictional versioning CLI
USAGE:
git <SUBCOMMAND>
OPTIONS:
-h, --help Print help information
SUBCOMMANDS:
add adds things
clone Clones repos
help Print this message or the help of the given subcommand(s)
push pushes things
stash
After:
A fictional versioning CLI
Usage: git <COMMAND>
Commands:
clone Clones repos
push pushes things
add adds things
stash
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help information
--version is available for showing the same thing (if the program has a version set)In talking to users, we found some that liked clap's man-like experience.
When deviating from this, we are making the assumption that those are more
power users and that the majority of users wouldn't look as favorably on being
consistent with man.
See Issue 4132 for more background.
More Dynamicism
Clap's API has focused on &str for performance but this can make
dealing with owned data difficult, like #[arg(default_value_t)] generating a
String from the default value.
Additionally, to avoid ArgMatches from borrowing (and for some features we
decided to forgo), clap took the &str argument IDs and hashed them. This
prevented us from providing a usable API for iterating over existing arguments.
Now clap has switched to a string newtype that gives us the flexibility to
decide whether to use &'static str, Cow<'static, str> for fast dynamic behavior, or
Box<str> for dynamic behavior with small binary size.
As an extension of that work, you can now call ArgMatches::ids to iterate
over the arguments and groups that were found when parsing. The newtype Id
was used to prevent some classes of bugs and to make it easier to understand
when opaque Ids are used vs user-visible strings.
Clearing Out Deprecations
Instead of doing all development on clap 4.0.0, we implemented a lot of new features during clap 3's development, deprecating the old API while introducing the new API, including:
ArgActionValueParser API
PathBuf (allowing invalid UTF-8)AppSettings and ArgSettings enums with getters/settersSteps:
-h and --help output at a minimum (recommendation: trycmd for snapshot testing)arg.action(ArgAction::...) on each argument (StoreValue for options and IncOccurrences for flags)cargo check --features clap/deprecated and resolve all deprecation warningsdefault-features = false, run cargo add clap -F help,usage,error-contextcargo add clap -F wrap_help unless you want to hard code line wrapsExample test (derive):
#[derive(clap::Parser)]
struct Cli {
...
}
#[test]
fn verify_cli() {
use clap::CommandFactory;
Cli::command().debug_assert()
}
Example test (builder):
fn cli() -> clap::Command {
...
}
#[test]
fn verify_cli() {
cli().debug_assert();
}
Note: the idiomatic / recommended way of specifying different types of args in the Builder API has changed:
Before
.arg(Arg::new("flag").long("flag")) # --flag
.arg(Arg::new("option").long("option").takes_value(true)) # --option <option>
After:
.arg(Arg::new("flag").long("flag").action(ArgAction::SetTrue)) # --flag
.arg(Arg::new("option").long("option")) # --option <option>
In particular, num_args (the replacement for takes_value) will default appropriately
from the ArgAction and generally only needs to be set explicitly for the
other num_args use cases.
Subtle changes (i.e. compiler won't catch):
arg! now sets one of (#3795):
ArgAction::SetTrue, requiring ArgMatches::get_flag instead of ArgMatches::is_presentArgAction::Count, requiring ArgMatches::get_count instead of ArgMatches::occurrences_ofArgAction::Set, requiring ArgMatches::get_one instead of ArgMatches::value_ofArgAction::Append, requiring ArgMatches::get_many instead of ArgMatches::values_ofArgAction::Set, ArgAction::SetTrue, and Arg::Action::SetFalse now
conflict by default to be like ArgAction::StoreValue and
ArgAction::IncOccurrences, requiring cmd.args_override_self(true) to override instead (#4261)Args default action is ArgAction::Set, rather than ArgAction::IncOccurrence to reduce confusing magic through consistency (#2687, #4032, see also #3977)mut_arg can no longer be used to customize help and version arguments, instead disable them (Command::disable_help_flag, Command::disable_version_flag) and provide your own (#4056)Command, Arg, ArgGroup, and PossibleValue, assuming 'static. string feature flag will enable support for Strings (#1041, #2150, #4223)arg!(--flag <value>) is now optional, instead of required. Add .required(true) at the end to restore the original behavior (#4206)help, usage and error-context, requiring adding them back in if default-features = false (#4236)"" argument for external subcommands to make it easier to distinguish them from built-in commands (#3263)Arg::allow_hyphen_values, to be consistent with Command::allow_hyphen_values (#4187)Arg::value_terminator must be its own argument on the CLI rather than being in a delimited list (#4025)wrap_help feature flag, either enable it or hard code your wraps (#4258)DeriveDisplayOrder the default and removed the setting. To sort help, set next_display_order(None) (#2808)Command::next_display_order instead of DeriveDisplayOrder and using its own initial display order value (#2808)Command::help_template (#4132)Command::help_template, Arg::help_heading, and Command::subcommand_help_heading (#4132)COMMAND for the value name. To get the old behavior, see Command::subcommand_help_heading and Arg::subcommand_value_name (#4132, #4155)Command::help_template. (#4132, #4160)--help and --version like any ArgAction::SetTrue flag (#3776)Arg::id as verbatim casing, requiring updating of string references to other args like in conflicts_with or requires (#3282)ValueEnum variants will now show up in --help (#3312)Args, and ArgGroup is created using the type's name, reserving it for future use (#2621, #4209)next_help_heading can now leak out of a #[clap(flatten)], like all other command settings (#4222)Easier to catch changes:
ArgMatches now returns the arg Ids, rather than the values to reduce overhead and offer more flexibility. (#4072)Arg::number_of_values (average-across-occurrences) to Arg::num_args (per-occurrence) (raw CLI args, not parsed values) (#2688, #4023)
num_args(0) no longer implies takes_value(true).multiple_values(true) (#4023)num_args(1) no longer implies multiple_values(true) (#4023)Arg::min_values (across all occurrences) with Arg::num_args(N..) (per occurrence) to reduce confusion over different value count APIs (#4023)Arg::max_values (across all occurrences) with Arg::num_args(1..=M) (per occurrence) to reduce confusion over different value count APIs (#4023)Arg::multiple_values(true) with Arg::num_args(1..) and Arg::multiple_values(false) with Arg::num_args(0) to reduce confusion over different value count APIs (#4023)Arg::takes_value(true) with Arg::num_args(1) and Arg::takes_value(false) with Arg::num_args(0) to reduce confusion over different value count APIsArg::require_value_delimiter, either users could use Arg::value_delimiter or implement a custom parser with TypedValueParser as it was mostly to make multiple_values(true) act like multiple_values(false) and isn't needed anymore (#4026)Arg::new("help") and Arg::new("version") no longer implicitly disable the
built-in flags and be copied to all subcommands, instead disable
the built-in flags (Command::disable_help_flag,
Command::disable_version_flag) and mark the custom flags as global(true). (#4056)Arg::short('h') no longer implicitly disables the short flag for help,
instead disable
the built-in flags (Command::disable_help_flag,
Command::disable_version_flag) provide your own Arg::new("help").long("help").action(ArgAction::Help).global(true). (#4056)ArgAction::SetTrue and ArgAction::SetFalse now prioritize Arg::default_missing_value over their standard behavior (#4000)Arg::requires_ifs and Arg::default_value*_ifs* to taking an ArgPredicate, removing ambiguity with None when accepting owned and borrowed types (#4084)PartialEq and Eq from Command so we could change external subcommands to use a ValueParser (#3990)Arg, Command, and ArgGroup calls were switched from accepting &[] to [] via IntoIterator to be more flexible (#4072)Arg::short_aliases and other builder functions that took &[] need the & dropped (#4081)ErrorKind and Result moved into the error moduleErrorKind::EmptyValue replaced with ErrorKind::InvalidValue to remove an unnecessary special case (#3676, #3968)ErrorKind::UnrecognizedSubcommand replaced with ErrorKind::InvalidSubcommand to remove an unnecessary special case (#3676)allow_external_subcommands from String to OsString as that is less likely to cause bugs in user applications (#3990)Command::render_usage now returns a StyledStr (#4248)parse to value_parser, removing parse support (#3827, #3981)
#[clap(value_parser)] and #[clap(action)] are now redundantsubcommand_required(true).arg_required_else_help(true) is set instead of SubcommandRequiredElseHelp to give more meaningful errors when subcommands are missing and to reduce redundancy (#3280)arg_enum attribute in favor of value_enum to match the new name (we didn't have support in v3 to mark it deprecated) (#4127)Arg::default_missing_value didn't require num_args(0..=N), now it does (#4023)Arg::long are no longer allowed (#3691)value_names than num_args (#2695)ArgAction::Version is used#[track_caller]s to make it easier to debug assertsoverrides_with IDs are validoverrides_with now that Actions replace itmut_arg receiving an invalid arg ID or mut_subcommand receiving an invalid command nameMSRV is now 1.60.0
Deprecated
Arg::use_value_delimiter in favor of Arg::value_delimiter to avoid having multiple ways of doing the same thingArg::requires_all in favor of Arg::requires_ifs now that it takes an ArgPredicate to avoid having multiple ways of doing the same thingArg::number_of_values in favor of Arg::num_args to clarify semantic differencesdefault_value_os, default_values_os, default_value_if_os, and default_value_ifs_os as the non _os variants now accept either a str or an OsStr (#4141)Arg::env_os in favor of Arg::envCommand::dont_collapse_args_in_usage is now the default (#4151)Command::trailing_var_arg in favor of Arg::trailing_var_arg to make it clearer which arg it is meant to apply to (#4187)Command::allow_hyphen_values in favor of Arg::allow_hyphen_values to make it clearer which arg it is meant to apply to (#4187)Command::allow_negative_numbers in favor of Arg::allow_negative_numbers to make it clearer which arg it is meant to apply to (#4187)Command::write_help and Command::write_long_help in favor of Command::render_help and Command::render_long_help (#4248)structopt and clap attributes in favor of the more specific command, arg, and value to open the door for more features and clarify relationship to the builder (#1807, #4180)#[clap(value_parser)] and #[clap(action)] defaulted attributes (its the default) (#3976)Behavior Changes
wrap_help feature, if the terminal size cannot be determined, LINES and COLUMNS variables are used (#4186)Arg::num_args now accepts ranges, allowing setting both the minimum and maximum number of values per occurrence (#2688, #4023)value_parsers for ArgAction::SetTrue / ArgAction::SetFalse (#4092)From<&OsStr>, From<OsString>, From<&str>, and From<String> to value_parser! (#4257)Command, Arg, ArgGroup, PossibleValue, etc without managing lifetimes with the string feature flag (#2150, #4223)error-context, help and usage feature flags that can be turned off for smaller binaries (#4236)StyledStr::ansi() to Display with ANSI escape codes (#4248)Error::apply for changing the formatter for dropping binary size (#4111)Error::renderfor formatting the error into a StyledStrPossibleValue::help in long help (--help) (#3312){tab} variable for Command::help_template (#4161)Command::render_help and Command::render_long_help for formatting the error into a StyledStr (#3873, #4248)Command::render_usage now returns a StyledStr (#4248)required is not used with conditional required settings (#3660)cmd.allow_invalid_for_utf8_external_subcommands with cmd.external_subcommand_value_parser (#3733)Arg::default_missing_value now applies per occurrence rather than if a value is missing across all occurrences (#3998)arg!(--long [value]) to accept 0..=1 per occurrence rather than across all occurrences, making it safe to use with ArgAction::Append (#4001)OsStrs for Arg::{required_if_eq,required_if_eq_any,required_if_eq_all} (#4084)wrap_help feature, if the terminal size cannot be determined, LINES and COLUMNS variables are used (#4186)Command::display_name in the help title rather than Command::bin_nameArgAction::Count by adding an ... (#4003)cmd help help (#4131)[positional] in list when relevant (#4144)[positional] in usage (#4151)-h / --help when applicable (#4132, #4159)next_line_help, don't add blank lines (#4132, #4190)Command::display_name rather than Command::bin_name (#3966)"" argument for external subcommands (#3263)Arg::allow_hyphen_values, like Command::allow_hyphen_values (#4187)InvalidSubcommand over UnknownArgument in more cases (#4219)Arg::id as verbatim casing (#3282)#[clap(value_parser, action)] instead of #[clap(parse)] (#3827)Nothing published for this version
*(derive)* Fix regression with #[clap(default_value_os_t ...)] introduced in v3.2.3
#[clap(default_value_os_t ...)] introduced in v3.2.3*(derive)* Provide more clearer deprecation messages for #[clap(parse)] attribute
#[clap(parse)] attribute (#3832)Moved deprecations to be behind the deprecated Cargo.toml feature
deprecated Cargo.toml feature (#3830)
*(derive)* Improve the highlighted code for deprecation warnings
gated behind unstable-v4
#[clap(value_parser, action)] instead of #[clap(parse)] (#3827)Nothing published for this version
Moving (old location deprecated)
MSRV is now 1.56.0 (#3732)
Behavior
required and its variants (#3793)ArgMatches::value_of and friends, debug asserts were turned into panicsMoving (old location deprecated)
clap::{PossibleValue, ValueHint} to clap::builder::{PossibleValue, ValueHint}clap::{Indices, OsValues, ValueSource, Values} to clap::parser::{Indices, OsValues, ValueSource, Values}clap::ArgEnum to clap::ValueEnum (#3799)Replaced
Arg::allow_invalid_utf8 with Arg::value_parser(value_parser!(PathBuf)) (#3753)Arg::validator / Arg::validator_os with Arg::value_parser (#3753)Arg::validator_regex with users providing their own builder::TypedValueParser (#3756)Arg::forbid_empty_values with builder::NonEmptyStringValueParser / builder::PathBufValueParser (#3753)Arg::possible_values with Arg::value_parser([...]), builder::PossibleValuesParser, or builder::EnumValueParser (#3753)Arg::max_occurrences with arg.action(ArgAction::Count).value_parser(value_parser!(u8).range(..N)) for flags (#3797)Arg::multiple_occurrences with ArgAction::Append or ArgAction::Count though positionals will need Arg::multiple_values (#3772, #3797)Command::args_override_self with ArgAction::Set (#2627, #3797)AppSettings::NoAutoVersion with ArgAction or Command::disable_version_flag (#3800)AppSettings::NoHelpVersion with ArgAction or Command::disable_help_flag / Command::disable_help_subcommand (#3800)ArgMatches::{value_of, value_of_os, value_of_os_lossy, value_of_t} with ArgMatches::{get_one,remove_one} (#3753)ArgMatches::{values_of, values_of_os, values_of_os_lossy, values_of_t} with ArgMatches::{get_many,remove_many} (#3753)ArgMatches::is_valid_arg with ArgMatches::{try_get_one,try_get_many} (#3753)ArgMatches::occurrences_of with ArgMatches::value_source or ArgAction::Count (#3797)ArgMatches::is_present with ArgMatches::contains_id or ArgAction::SetTrue (#3797)ArgAction::StoreValue with ArgAction::Set or ArgAction::Append (#3797)ArgAction::IncOccurrences with ArgAction::SetTrue or ArgAction::Count (#3797)#[clap(parse(...))] replaced with: (#3589, #3794)
parse attribute), deprecation warnings can be
silenced by opting into the new behavior by adding either #[clap(action)]
or #[clap(value_parser)] (ie requesting the default behavior for these
attributes). Alternatively, the unstable-v4 feature changes the default
away from parse to action/value_parser.#[clap(parse(from_flag))] replaced with #[clap(action = ArgAction::SetTrue)] (#3794)#[clap(parse(from_occurrences))] replaced with #[clap(action = ArgAction::Count)] though the field's type must be u8 (#3794)#[clap(parse(from_os_str)] for PathBuf, replace it with
#[clap(value_parser)] (as mentioned earlier this will call
value_parser!(PathBuf) which will auto-select the right ValueParser
automatically).#[clap(parse(try_from_str = ...)], replace it with #[clap(value_parser = ...)]TypedValueParser will be needed and specify it with #[clap(value_parser = ...)]Arg::value_parser / ArgMatches::{get_one,get_many} (#2683, #3732)
TypedValueParsers available with an API open for expansionvalue_parser!(T) macro for selecting a parser for a given type (#3732) and open to expansion via the ValueParserFactory trait (#3755)[&str] is implicitly a value parser for possible valuesArgMatches getters do not assume required arguments (#2505)ArgMatches::remove_* variants to transfer ownershipArgMatches::try_* variants to avoid panics for developer errors (#3621)get_raw to access the underlying OsStrsPathBuf value parsers imply ValueHint::AnyPath for completions (#3732)Arg::action (#3774)
ArgAction::StoreValue: existing takes_value(true) behaviorArgAction::IncOccurrences: existing takes_value(false) behaviorArgAction::Help: existing --help behaviorArgAction::Version: existing --version behaviorArgAction::Set: Overwrite existing values (like Arg::multiple_occurrences mixed with Command::args_override_self) (#3777)ArgAction::Append: like Arg::multiple_occurrences (#3777)ArgAction::SetTrue: Treat --flag as --flag=true (#3775)
Arg::default_value("false") (#3786)Arg::env via Arg::value_parserArgAction::SetFalse: Treat --flag as --flag=false (#3775)
Arg::default_value("true") (#3786)Arg::env via Arg::value_parserArgAction::Count: Treat --flag --flag --flag as --flag=1 --flag=2 --flag=3 (#3775)
Arg::default_value("0") (#3786)Arg::env via Arg::value_parserArg::value_parser / Arg::action with either #[clap(value_parser)] (#3589, #3742) / #[clap(action)] attributes (#3794)
ValueParser is determined by value_parser! (#3199, #3496)ArgAction is determine by a hard-coded lookup on the type (#3794)Command::multicall is now stable for busybox-like programs and REPLs (#2861, #3684)ArgMatches::{try_,}contains_id for checking if there are values for an argument that mirrors the new get_{one,many} APIdefault_value_ifs_os(#3815)parser
ArgMatches::value_source and ArgMatches::occurrences_of for external subcommands (#3732)Arg::default_missing_values (#3761, #3765)Arg::default_value / Arg::env on value delimiters independent of whether -- was used (#3765)required and its variants (#3793)Your coding agent can read these notes before it upgrades. Set up the MCP server →