# 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.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