# Change Log All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## 5.0.0 - 2022-11-24 ### Breaking Changes - Made `ArgPredicate` `non_exhaustive` - *(help)* Change default `Command::term_width` to "source format" - *(help)* Change default `Command::max_term_width` to 100 - *(derive)* `Vec>` types are now assuming to capture occurrences ### Features - *(derive)* Group values by their occurrence with `Vec>` ## [Unreleased] - ReleaseDate ## [4.5.17] - 2024-09-04 ### Fixes - *(help)* Style required argument groups - *(derive)* Improve error messages when unsupported fields are used ## [4.5.16] - 2024-08-15 ### Fixes - *(derive)* Improve error messages when `derive` feature is missing ## [4.5.15] - 2024-08-10 ### Compatiblity - *(unstable-ext)* `Arg::remove` changed return types ### Fixes - *(unstable-ext)* Make `Arg::remove` return the removed item ## [4.5.14] - 2024-08-08 ### Features - *(unstable-ext)* Added `Arg::add` for attaching arbitrary state, like completion hints, to `Arg` without `Arg` knowing about it ## [4.5.13] - 2024-07-31 ### Fixes - *(derive)* Improve error message when `#[flatten]`ing an optional `#[group(skip)]` - *(help)* Properly wrap long subcommand descriptions in help ## [4.5.12] - 2024-07-31 ## [4.5.11] - 2024-07-25 ## [4.5.10] - 2024-07-23 ## [4.5.9] - 2024-07-09 ### Fixes - *(error)* When defining a custom help flag, be sure to suggest it like we do the built-in one ## [4.5.8] - 2024-06-28 ### Fixes - Reduce extra flushes ## [4.5.7] - 2024-06-10 ### Fixes - Clean up error message when too few arguments for `num_args` ## [4.5.6] - 2024-06-06 ## [4.5.5] - 2024-06-06 ### Fixes - Allow `exclusive` to override `required_unless_present`, `required_unless_present_any`, `required_unless_present_all` ## [4.5.4] - 2024-03-25 ### Fixes - *(derive)* Allow non-literal `#[arg(id)]` attributes again ## [4.5.3] - 2024-03-15 ### Internal - *(derive)* Update `heck` ## [4.5.2] - 2024-03-06 ### Fixes - *(macros)* Silence a warning ## [4.5.1] - 2024-02-16 ### Fixes - *(error)* Include suggestion to add `--` even if there is a "did you mean" so long as `last` or `trailing_var_arg` is used ## [4.5.0] - 2024-02-08 ### Compatibility - Update MSRV to 1.74 ## [4.4.18] - 2024-01-16 ### Fixes - *(error)* When lacking `usage` feature, ensure the list of required arguments is unique ## [4.4.17] - 2024-01-15 ### Fixes - Fix `panic!` when mixing `args_conflicts_with_subcommands` with `ArgGroup` (which is implicit with `derive`) introduced in 4.4.15 ## [4.4.16] - 2024-01-12 ### Fixes - Ensure invalid escape sequences in user-defined strings are correctly stripped when terminal doesn't support color ## [4.4.15] - 2024-01-11 ### Fixes - Improve error for `args_conflicts_with_subcommands` - Ensure we error for `args_conflicts_with_subcommands` when using subcommand short and long flags ## [4.4.14] - 2024-01-08 ### Documentation - Fix `find` cookbook entry to allow repeats of flags/options ### Features - Allow `num_args(0)` on options which allows making them emulate being a flag for position-tracking flags ## [4.4.13] - 2024-01-04 ### Documentation - Fix link to structopt migration guide ## [4.4.12] - 2023-12-28 ### Performance - Only ask `TypedValueParser` for possible values if needed ## [4.4.11] - 2023-12-04 ### Features - Add `Command::mut_group` ## [4.4.10] - 2023-11-28 ### Documentation - Link out to changelog - Cross link derive's attribute reference to derive tutorial ## [4.4.9] - 2023-11-27 ### Fixes - *(help)* Show correct `Command::about` under flattened headings - *(help)* Respect `hide` when flattening subcommands ## [4.4.8] - 2023-11-10 ### Features - Add `Command::flatten_help` to allow `git stash -h` like help for subcommands ## [4.4.7] - 2023-10-24 ### Performance - Reduced code size ## [4.4.6] - 2023-09-28 ### Internal - Upgrade `anstream` ## [4.4.5] - 2023-09-25 ### Fixes - *(parser)* When inferring subcommand `name` or `long_flag`, allow ambiguous-looking matches that unambiguously map back to the same command - *(parser)* When inferring subcommand `long_flag`, don't panic - *(assert)* Clarify what action is causing a positional that doesn't set values which is especially useful for derive users ## [4.4.4] - 2023-09-18 ### Internal - Update `terminal_size` to 0.3 ## [4.4.3] - 2023-09-12 ### Documentation - *(derive)* Clarify use of attributes within the tutorial - Split sections in the builder and derive tutorials into separate modules ## [4.4.2] - 2023-08-31 ### Performance - Improve build times by removing `once_cell` dependency ## [4.4.1] - 2023-08-28 ### Features - Stabilize `Command::styles` ## [4.4.0] - 2023-08-24 ### compatibility - update msrv to 1.70.0 ## [4.3.24] - 2023-08-23 ### Fixes - Ensure column padding is preserved in `--help` with custom templates ## [4.3.23] - 2023-08-18 ### Fixes - Fixed `UnknownArgumentValueParser` to not error on flag's absence ## [4.3.22] - 2023-08-17 ### Features - Add `UnknownArgumentValueParser` for injecting errors for improving the experience with errors ## [4.3.21] - 2023-08-08 ### Features - Expose `TryMapValueParser` so the type can be named ## [4.3.20] - 2023-08-08 ### Features - `Command::mut_args` for modifying all arguments en masse ## [4.3.19] - 2023-07-21 ### Fixes - *(parse)* Respect `value_terminator` even in the presence of later multiple-value positional arguments ## [4.3.18] - 2023-07-21 ### Fixes - *(parse)* Suggest `--` in fewer places where it won't work ## [4.3.17] - 2023-07-19 ### Fixes - *(help)* Address a regression in wrapping `PossibleValue` descriptions in `--help` ## [4.3.16] - 2023-07-18 ### Fixes - Don't assert when stateful value parsers fail on defaults (e.g. checking if a path exists) ## [4.3.15] - 2023-07-18 ### Features - *(unstable-styles)* Re-export `anstyle` ### Documentation - *(unstable-styles)* Provide more examples ## [4.3.14] - 2023-07-17 ### Features - `ArgAction::HelpShort` and `ArgAction::HelpLong` for explicitly specifying which style of help to display ### Fixes - Skip `[OPTIONS]` in usage if a help or version `ArgAction` is used ## [4.3.13] - 2023-07-17 ## [4.3.12] - 2023-07-14 ### Fixes - *(derive)* Don't error on enum variant field attributes ## [4.3.11] - 2023-07-05 ### Features - *(derive)* Support fields wrapped in `num::Wrapping`, `Box`, or `Arc` - *(derive)* Support `Box`, `Box`, and `Box` ## [4.3.10] - 2023-06-30 ### Performance - Drop a dependency, reducing binary size by 1.3 KiB ## [4.3.9] - 2023-06-28 ### Fixes - `Command::ignore_errors` no longer masks help/version ## [4.3.8] - 2023-06-23 ### Fixes - Error on ambiguity with `infer_long_arg`, rather than arbitrarily picking one, matching the documentation and subcommand's behavior ## [4.3.7] - 2023-06-23 ### Documentation - Further clarify magic behavior in derive tutorial - Further clarify derive API's relationship to builder within the tutorial ## [4.3.6] - 2023-06-23 ### Documentation - Suggest `clio` ## [4.3.5] - 2023-06-20 - `ColorChoice::possible_values` is added to simplify things for builder users ### Fixes - `ColorChoice::to_possible_value` no longer includes descriptions, encouraging shorter help where possible ## [4.3.4] - 2023-06-14 ### Features - Add `Error::exit_code` ## [4.3.3] - 2023-06-09 ### Features - `Command::defer` for delayed initialization of subcommands to reduce startup times of large applications like deno ## [4.3.2] - 2023-06-05 ### Fixes - *(derive)* Don't produce `unused_equalifications` warnings when someone brings a clap type into scope ## [4.3.1] - 2023-06-02 ### Performance - *(derive)* Reduce the amount of generated code ## [4.3.0] - 2023-05-19 ### Fixes - *(assert)* Allow multiple, value-terminated, positional arguments - *(assert)* Clear up language on `last` assertion - *(parser)* Correctly assign values to arguments when using multiple, value-termianted, positional arguments - *(parser)* Ensure `value_terminator` has higher precedence than `allow_hyphen_values` - *(help)* Only use next-line-help on subcommand list when explicitly specified, not just with `--help` - *(help)* Correctly align possible values list - *(help)* Don't waste code, vertical space in moving possible value descriptions to next line ## [4.2.7] - 2023-05-02 ### Fixes - Correctly track remaining length for iterators provided by `ArgMatches` ## [4.2.6] - 2023-05-02 ### Features - `impl Eq for clap_builder::util::AnyValueId` ## [4.2.5] - 2023-04-27 ### Fixes - Improve panic when a group requires a non-existent ID ## [4.2.4] - 2023-04-19 ### Documentation - Corrected docs for `Command::style` ## [4.2.3] - 2023-04-18 ### Features - `Command::styles` for theming help/errors (behind `unstable-styles`) ## [4.2.2] - 2023-04-13 ### Internal - Update dependencies ## [4.2.1] - 2023-03-28 ### Fixes - Don't highlight uninteresting parts of the error message ## [4.2.0] - 2023-03-28 ### Compatibility - Removed the languishing `unstable-replace` feature (open to discussion at [#2836](https://github.com/clap-rs/clap/issues/2836)) - Removed the stablized `unstable-grouped` feature ### Features - Allow any `StyledStr` to accept text styled with ANSI escape codes - Respect `CLICOLOR`, `CLICOLOR_FORCE` ### Fixes - Lighten the tone for "unexpected argument" errors (open to discussion at [#4638](https://github.com/clap-rs/clap/issues/4638)) ## [4.1.14] - 2023-03-28 ### Features - *(derive)* `#[group]` raw attribute support ### Performance - *(derive)* `clap_builder` was pulled out of `clap` so it could build in parallel to `clap_derive` - `os_str_bytes` dependency was removed for faster builds and smaller binaries ## [4.1.13] - 2023-03-18 ### Performance - Reduce repeated alloc calls when building a `Command` - Reduce duplicate dependencies for faster builds ## [4.1.12] - 2023-03-18 ### Internal - *(derive)* Update to `syn` v2 ### Performance - *(derive)* Faster build times by dropping `proc-macro-error` dependency ## [4.1.11] - 2023-03-17 ### Internal - Update `bitflags` ## [4.1.10] - 2023-03-17 ### Fixes - *(help)* On Windows, avoid underlined text artifacts ## [4.1.9] - 2023-03-16 ### Fixes - *(assert)* Improve the assert when using the wrong action with `get_count` / `get_flag` ## [4.1.8] - 2023-02-27 ### Fixes - *(derive)* Don't `deny` lints on the users behalf ## [4.1.7] - 2023-02-27 ### Fixes - *(derive)* Hide some nightly clippy warnings ## [4.1.6] - 2023-02-15 ### Fixes - *(help)* Don't show long help for `--help` just because hidden possible values include a description ## [4.1.5] - 2023-02-15 ### Fixes - *(help)* Don't show long help for `--help` just because a hidden arg has a possible value with a description ## [4.1.4] - 2023-01-24 ### Fixes - *(help)* Respect `disable_colored_help` when using `arg_required_else_help` ### Performance - Speed up compiling `arg!` macro ## [4.1.3] - 2023-01-23 ### Fixes - *(error)* Improve suggested flag/value/subcommand when two share a long preifx - *(error)* When suggesting one of several subcommands, use the plural `subcommands`, rather than `subcommand` ## [4.1.2] - 2023-01-23 ### Fixes - In documentation, refer to `get_flag`, rather than `get_one::` ## [4.1.1] - 2023-01-14 ### Fixes - *(error)* Small softening attempt for "unexpected argument" error ## [4.1.0] - 2023-01-13 ### Compatibility MSRV changed to 1.64.0 For apps with custom `--help` and `--version` flags: - Descriptions for `--help` and `--version` changed When apps have errors imitating clap's error style: - Error message style was changed, including - Moving away from "did you mean" to tips - Leading letter is lower case - "For more" added some punctuation ### Features - `ArgMatches::get_occurrences` support for argument values to be grouped by their occurrence ### Fixes - *(derive)* Allow `upgrade_from` when arguments / subcommands are explicitly marked as required - *(help)* Try be more clearer and succinct with `--help` and `--version` (also helps with overflow) - *(error)* Try to be more clearer and succinct with error messages - *(error)* Officially adopt [an error style guide](https://rustc-dev-guide.rust-lang.org/diagnostics.html#suggestion-style-guide) ## [4.0.32] - 2022-12-22 ### Fixes - *(parser)* When overriding `required(true)`, consider args that conflict with its group ## [4.0.31] - 2022-12-22 ### Performance - Speed up parsing when a lot of different flags are present (100 unique flags) ## [4.0.30] - 2022-12-21 ### Fixes - *(error)* Improve error for `args_conflicts_with_subcommand` ## [4.0.29] - 2022-11-29 ## [4.0.28] - 2022-11-29 ### Fixes - Fix wasm support which was broken in 4.0.27 ## [4.0.27] - 2022-11-24 ### Features - Have `Arg::value_parser` accept `Vec>` - Implement `Display` and `FromStr` for `ColorChoice` ### Fixes - Remove soundness issue by switching from `atty` to `is-terminal` ## [4.0.26] - 2022-11-16 ### Fixes - *(error)* Fix typos in `ContextKind::as_str` ## [4.0.25] - 2022-11-15 ### Features - *(error)* Report available subcommands when required subcommand is missing ## [4.0.24] - 2022-11-14 ### Fixes - Avoid panic when printing an argument that isn't built ## [4.0.23] - 2022-11-11 ### Fixes - Don't panic on reporting invalid-long errors when followed by invalid UTF8 - *(help)* Clarified argument to `help` subcommand ## [4.0.22] - 2022-11-07 ### Fixes - *(help)* Don't overflow into next-line-help early due to stale (pre-v4) padding calculations ## [4.0.21] - 2022-11-07 ### Features - *(derive)* `long_about` and `long_help` attributes, without a value, force using doc comment (before it wouldn't be set if there wasn't anything different than the short help) ## [4.0.20] - 2022-11-07 ### Fixes - *(derive)* Allow defaulted value parser for '()' fields ## [4.0.19] - 2022-11-04 ### Features - `ColorChoice` now implements `ValueEnum` ## [4.0.18] - 2022-10-20 ### Fixes - *(derive)* Allow `#[command(skip)]` to also work with enum variants with a value ## [4.0.17] - 2022-10-18 ### Fixes - Allow using `Arg::last(true)` with `Arg::value_hint(ValueHint::CommandWithArguments)` ## [4.0.16] - 2022-10-18 ### Fixes - `Arg::exclusive(true)` should not be exclusive with the argument's own `ArgGroup` ## [4.0.15] - 2022-10-13 ### Fixes - *(error)* Don't suggest `--` when it doesn't help - *(error)* Be more consistent in quoting, punctuation, and indentation in errors ## [4.0.14] - 2022-10-12 ### Fixes - Only put `ArgGroup` in `ArgMatches` when explicitly specified, fixing derives handling of option-flattened fields (#4375) ## [4.0.13] - 2022-10-11 ### Features - *(derive)* Allow `()` for fields to mean "don't read" (#4371) ## [4.0.12] - 2022-10-10 ### Features - Added `TypedValueParser::try_map` for when adapting an existing `TypedValueParser` can fail - *(error)* Create errors like clap with `Error::new`, `Error::with_cmd`, and `Error::insert` ## [4.0.11] - 2022-10-09 ### Fixes - *(help)* Fix wrapping calculations with ANSI escape codes ## [4.0.10] - 2022-10-05 ### Features - *(derive)* Support `#[arg(flatten)]` on `Option` types (#4211, #4350) ## [4.0.9] - 2022-10-03 ### Fixes - *(derive)* Process doc comments for `#[command(subcommand)]` like in clap v3 ## [4.0.8] - 2022-10-01 ### Fixes - *(derive)* Remove a low-value assert preventing defaulting `Help` and `Version` actions ## [4.0.7] - 2022-09-30 ### Features - *(derive)* Populate implicit ArgGroup (#3165) ### Fixes - *(derive)* Support `#[group(skip)]` on `Parser` derive - *(derive)* Tell users about implicit arg groups when running into group name conflicts - *(error)* Don't report unrelated groups in conflict or requires errors ## [4.0.6] - 2022-09-30 ### Features - *(derive)* Support `#[group(skip)]` (#4279, #4301) ## [4.0.5] - 2022-09-30 ## [4.0.4] - 2022-09-29 ### Fixes - *(error)* Specialize the self-conflict error to look like clap v3 ## [4.0.3] - 2022-09-29 ### Fixes - *(error)* Quote literals consistently - *(error)* Stylize escape (`--`) suggestions - *(error)* Format help flag as a literal ## [4.0.2] - 2022-09-28 ### Fixes - *(parser)* `SetFalse` should conflict with itself like `SetTrue` and `Set` - *(parser)* Allow one-off overrides ## [4.0.1] - 2022-09-28 ### Fixes - *(derive)* Ensure `#[clap(...)]` attribute still works ## [4.0.0] - 2022-09-28 ### Highlights **`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](https://github.com/clap-rs/clap/issues/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: - Whether other CLIs had ideas that make sense to apply - Providing an experience that fits within the rest of applications and works across all shells Before: ``` git A fictional versioning CLI USAGE: git 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 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 ``` - name/version header was removed because we couldn't justify the space it occupied when - Usage already includes the name - `--version` is available for showing the same thing (if the program has a version set) - Usage was dropped to one line to save space - Focus is put on the subcommands - Headings are now Title case - The more general term "command" is used rather than being explicit about being "subcommands" - The output is more dense with the expectation that it won't affect legibility but will allow more content - We've moved to a more neutral palette for highlighting elements (not highlighted above) 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](https://github.com/clap-rs/clap/issues/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` 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: - Replacing the implicit behavior for args when parsing them with `ArgAction` - Replacing various one-off forms of value validation with the `ValueParser` API - Allowing derives to automatically do the right thing for `PathBuf` (allowing invalid UTF-8) - Replacing `AppSettings` and `ArgSettings` enums with getters/setters - Clarifying terms and making them more consistent ### Migrating Steps: 0. [Upgrade to v3](https://github.com/clap-rs/clap/blob/v3-master/CHANGELOG.md#migrating) if you haven't already 1. Add CLI tests (including example below), `-h` and `--help` output at a minimum (recommendation: [trycmd](https://docs.rs/trycmd/) for snapshot testing) 2. *If using Builder API*: Explicitly set the `arg.action(ArgAction::...)` on each argument (`StoreValue` for options and `IncOccurrences` for flags) 3. Run `cargo check --features clap/deprecated` and resolve all deprecation warnings 4. Upgrade to v4 5. Update feature flags - *If `default-features = false`*, run `cargo add clap -F help,usage,error-context` - Run `cargo add clap -F wrap_help` unless you want to hard code line wraps 6. Resolve compiler errors 7. Resolve behavior changes (see "subtle changes" under BREAKING CHANGES) 8. *At your leisure:* resolve new deprecation notices Example test (derive): ```rust #[derive(clap::Parser)] struct Cli { ... } #[test] fn verify_cli() { use clap::CommandFactory; Cli::command().debug_assert() } ``` Example test (builder): ```rust 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 ```rust .arg(Arg::new("flag").long("flag")) # --flag .arg(Arg::new("option").long("option").takes_value(true)) # --option