Update Rust crate clap to v4 #4

Open
renovatebot wants to merge 1 commit from renovate/clap-4.x into main
Collaborator

This PR contains the following updates:

Package Type Update Change
clap dependencies major 2.33 -> 4.0

Release Notes

clap-rs/clap (clap)

v4.5.51

Compare Source

Fixes
  • (help) Correctly calculate padding for short flags that take a value
  • (help) Don't panic on short flags using ArgAction::Count

v4.5.50

Compare Source

Features
  • Accept Cow where String and &str are accepted

v4.5.49

Compare Source

Fixes
  • (help) Correctly wrap when ANSI escape codes are present

v4.5.48

Compare Source

Documentation
  • Add a new CLI Concepts document as another way of framing clap
  • Expand the typed_derive cookbook entry

v4.5.47

Compare Source

Features
  • Added impl FromArgMatches for ()
  • Added impl Args for ()
  • Added impl Subcommand for ()
  • Added impl FromArgMatches for Infallible
  • Added impl Subcommand for Infallible
Fixes
  • (derive) Update runtime error text to match clap

v4.5.46

Compare Source

Features
  • Expose StyledStr::push_str

v4.5.45

Compare Source

Fixes
  • (unstable-v5) ValueEnum variants now use the full doc comment, not summary, for PossibleValue::help

v4.5.44

Compare Source

Features
  • Add Command::mut_subcommands

v4.5.43

Compare Source

Fixes
  • (help) In long help, list Possible Values before defaults, rather than after, for a more consistent look

v4.5.42

Compare Source

Fixes
  • Include subcommand visible long aliases in --help

v4.5.41

Compare Source

Features
  • Add Styles::context and Styles::context_value to customize the styling of [default: value] like notes in the --help

v4.5.40

Compare Source

Features
  • Support quoted ids in arg!() macro (e.g. arg!("check-config": ...))

v4.5.39

Compare Source

Fixes
  • (help) Show short flag aliases before long
  • (help) Merge the short and long flag alias lists

v4.5.38

Compare Source

Fixes
  • (help) When showing aliases, include leading -- or -

v4.5.37

Compare Source

Features
  • Added ArgMatches::try_clear_id()

v4.5.36

Compare Source

Fixes
  • (help) Revert 4.5.35's "Don't leave space for shorts if there are none" for now

v4.5.35

Compare Source

Fixes
  • (help) Align positionals and flags when put in the same help_heading
  • (help) Don't leave space for shorts if there are none

v4.5.34

Compare Source

Fixes
  • (help) Don't add extra blank lines with flatten_help(true) and subcommands without arguments

v4.5.33

Compare Source

Fixes
  • (error) When showing the usage of a suggestion for an unknown argument, don't show the group

v4.5.32

Compare Source

Features
  • Add Error::remove
Documentation
  • (cookbook) Switch from humantime to jiff
  • (tutorial) Better cover required vs optional
Internal
  • Update pulldown-cmark

v4.5.31

Compare Source

Features
  • Add ValueParserFactory for Saturating<T>

v4.5.30

Compare Source

Fixes
  • (assert) Allow num_args(0..=1) to be used with SetTrue
  • (assert) Clean up rendering of takes_values assertions

v4.5.29

Compare Source

Fixes
  • Change ArgMatches::args_present so not-present flags are considered not-present (matching the documentation)

v4.5.28

Compare Source

Features
  • (derive) Unstable support for full markdown syntax for doc comments, enabled with unstable-markdown

v4.5.27

Compare Source

Documentation
  • Iterate on tutorials and reference based on feedback

v4.5.26

Compare Source

Fixes
  • (error) Reduce binary size with the suggestions feature

v4.5.25

Compare Source

Fixes
  • (help) Reduce binary size

v4.5.24

Compare Source

Fixes
  • (parser) Correctly handle defaults with ignore_errors(true) and when a suggestion is provided for an unknown argument

v4.5.23

Compare Source

Fixes
  • (parser) When check allow_negative_numbers, allow E again

v4.5.22

Compare Source

Fixes
  • (assert) Catch bugs with arguments requiring themself

v4.5.21

Compare Source

Fixes
  • (parser) Ensure defaults are filled in on error with ignore_errors(true)

v4.5.20

Compare Source

Features
  • (unstable) Add CommandExt

v4.5.19

Compare Source

Internal
  • Update dependencies

v4.5.18

Compare Source

Features
  • (builder) Expose Arg::get_display_order and Command::get_display_order

v4.5.17

Compare Source

Fixes
  • (help) Style required argument groups
  • (derive) Improve error messages when unsupported fields are used

v4.5.16

Compare Source

Fixes
  • (derive) Improve error messages when derive feature is missing

v4.5.15

Compare Source

Compatiblity
  • (unstable-ext) Arg::remove changed return types
Fixes
  • (unstable-ext) Make Arg::remove return the removed item

v4.5.14

Compare Source

Features
  • (unstable-ext) Added Arg::add for attaching arbitrary state, like completion hints, to Arg without Arg knowing about it

v4.5.13

Compare Source

Fixes
  • (derive) Improve error message when #[flatten]ing an optional #[group(skip)]
  • (help) Properly wrap long subcommand descriptions in help

v4.5.12

Compare Source

v4.5.11

Compare Source

v4.5.10

Compare Source

v4.5.9

Compare Source

Fixes
  • (error) When defining a custom help flag, be sure to suggest it like we do the built-in one

v4.5.8

Compare Source

Fixes
  • Reduce extra flushes

v4.5.7

Compare Source

Fixes
  • Clean up error message when too few arguments for num_args

v4.5.6

Compare Source

v4.5.5

Compare Source

Fixes
  • (help) Correctly calculate padding for short flags that take a value
  • (help) Don't panic on short flags using ArgAction::Count

v4.5.4

Compare Source

Fixes
  • (help) Correctly wrap when ANSI escape codes are present

v4.5.3

Compare Source

Fixes
  • (help) Show short flag aliases before long
  • (help) Merge the short and long flag alias lists

v4.5.2

Compare Source

Fixes
  • Change ArgMatches::args_present so not-present flags are considered not-present (matching the documentation)

v4.5.1

Compare Source

Internal
  • Update dependencies

v4.5.0

Compare Source

Compatibility
  • Update MSRV to 1.74

v4.4.18

Compare Source

Fixes
  • (error) When lacking usage feature, ensure the list of required arguments is unique

v4.4.17

Compare Source

Fixes
  • Fix panic! when mixing args_conflicts_with_subcommands with ArgGroup (which is implicit with derive) introduced in 4.4.15

v4.4.16

Compare Source

Fixes
  • Ensure invalid escape sequences in user-defined strings are correctly stripped when terminal doesn't support color

v4.4.15

Compare Source

Fixes
  • Improve error for args_conflicts_with_subcommands
  • Ensure we error for args_conflicts_with_subcommands when using subcommand short and long flags

v4.4.14

Compare Source

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

v4.4.13

Compare Source

Documentation
  • Fix link to structopt migration guide

v4.4.12

Compare Source

Performance
  • Only ask TypedValueParser for possible values if needed

v4.4.11

Compare Source

Features
  • Add Command::mut_group

v4.4.10

Compare Source

Documentation
  • Link out to changelog
  • Cross link derive's attribute reference to derive tutorial

v4.4.9

Compare Source

Fixes
  • (help) Show correct Command::about under flattened headings
  • (help) Respect hide when flattening subcommands

v4.4.8

Compare Source

Features
  • Add Command::flatten_help to allow git stash -h like help for subcommands

v4.4.7

Compare Source

Performance
  • Reduced code size

v4.4.6

Compare Source

Internal
  • Upgrade anstream

v4.4.5

Compare Source

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

v4.4.4

Compare Source

Internal
  • Update terminal_size to 0.3

v4.4.3

Compare Source

Documentation
  • (derive) Clarify use of attributes within the tutorial
  • Split sections in the builder and derive tutorials into separate modules

v4.4.2

Compare Source

Performance
  • Improve build times by removing once_cell dependency

v4.4.1

Compare Source

Fixes
  • (error) When lacking usage feature, ensure the list of required arguments is unique

v4.4.0

Compare Source

compatibility
  • update msrv to 1.70.0

v4.3.24

Compare Source

Fixes
  • Ensure column padding is preserved in --help with custom templates

v4.3.23

Compare Source

Fixes
  • Fixed UnknownArgumentValueParser to not error on flag's absence

v4.3.22

Compare Source

Features
  • Add UnknownArgumentValueParser for injecting errors for improving the experience with errors

v4.3.21

Compare Source

Features
  • Expose TryMapValueParser so the type can be named

v4.3.20

Compare Source

Features
  • Command::mut_args for modifying all arguments en masse

v4.3.19

Compare Source

Fixes
  • (parse) Respect value_terminator even in the presence of later multiple-value positional arguments

v4.3.18

Compare Source

Fixes
  • (parse) Suggest -- in fewer places where it won't work

v4.3.17

Compare Source

Fixes
  • (help) Address a regression in wrapping PossibleValue descriptions in --help

v4.3.16

Compare Source

Fixes
  • Don't assert when stateful value parsers fail on defaults (e.g. checking if a path exists)

v4.3.15

Compare Source

Features
  • (unstable-styles) Re-export anstyle
Documentation
  • (unstable-styles) Provide more examples

v4.3.14

Compare Source

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

v4.3.13

Compare Source

v4.3.12

Compare Source

Fixes
  • (derive) Don't error on enum variant field attributes

v4.3.11

Compare Source

Features
  • (derive) Support fields wrapped in num::Wrapping, Box, or Arc
  • (derive) Support Box<str>, Box<OsStr>, and Box<Path>

v4.3.10

Compare Source

Performance
  • Drop a dependency, reducing binary size by 1.3 KiB

v4.3.9

Compare Source

Fixes
  • Command::ignore_errors no longer masks help/version

v4.3.8

Compare Source

Fixes
  • Error on ambiguity with infer_long_arg, rather than arbitrarily picking one, matching the documentation and subcommand's behavior

v4.3.7

Compare Source

Documentation
  • Further clarify magic behavior in derive tutorial
  • Further clarify derive API's relationship to builder within the tutorial

v4.3.6

Compare Source

Documentation
  • Suggest clio

v4.3.5

Compare Source

  • 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

v4.3.4

Compare Source

Features
  • Add Error::exit_code

v4.3.3

Compare Source

Features
  • Command::defer for delayed initialization of subcommands to reduce startup times of large applications like deno

v4.3.2

Compare Source

Fixes
  • Ensure column padding is preserved in --help with custom templates

v4.3.1

Compare Source

Fixes
  • (parse) Respect value_terminator even in the presence of later multiple-value positional arguments

v4.3.0

Compare Source

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

v4.2.7

Compare Source

Fixes
  • Correctly track remaining length for iterators provided by ArgMatches

v4.2.6

Compare Source

Features
  • impl Eq<std::any::TypeId> for clap_builder::util::AnyValueId

v4.2.5

Compare Source

Fixes
  • Improve panic when a group requires a non-existent ID

v4.2.4

Compare Source

Documentation
  • Corrected docs for Command::style

v4.2.3

Compare Source

Features
  • Command::styles for theming help/errors (behind unstable-styles)

v4.2.2

Compare Source

Internal
  • Update dependencies

v4.2.1

Compare Source

Fixes
  • Don't highlight uninteresting parts of the error message

v4.2.0

Compare Source

Compatibility
  • Removed the languishing unstable-replace feature (open to discussion at #​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)

v4.1.14

Compare Source

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

v4.1.13

Compare Source

Performance
  • Reduce repeated alloc calls when building a Command
  • Reduce duplicate dependencies for faster builds

v4.1.12

Compare Source

Internal
  • (derive) Update to syn v2
Performance
  • (derive) Faster build times by dropping proc-macro-error dependency

v4.1.11

Compare Source

Internal
  • Update bitflags

v4.1.10

Compare Source

Fixes
  • (help) On Windows, avoid underlined text artifacts

v4.1.9

Compare Source

Fixes
  • (assert) Improve the assert when using the wrong action with get_count / get_flag

v4.1.8

Compare Source

Fixes
  • (derive) Don't deny lints on the users behalf

v4.1.7

Compare Source

Fixes
  • (derive) Hide some nightly clippy warnings

v4.1.6

Compare Source

Fixes
  • (help) Don't show long help for --help just because hidden possible values include a description

v4.1.5

Compare Source

Fixes
  • (help) Don't show long help for --help just because a hidden arg has a possible value with a description

v4.1.4

Compare Source

Fixes
  • (help) Respect disable_colored_help when using arg_required_else_help
Performance
  • Speed up compiling arg! macro

v4.1.3

Compare Source

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

v4.1.2

Compare Source

Fixes
  • In documentation, refer to get_flag, rather than get_one::<bool>

v4.1.1

Compare Source

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

v4.1.0

Compare Source

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

v4.0.32

Compare Source

Fixes
  • (parser) When overriding required(true), consider args that conflict with its group

v4.0.31

Compare Source

Performance
  • Speed up parsing when a lot of different flags are present (100 unique flags)

v4.0.30

Compare Source

Fixes
  • (error) Improve error for args_conflicts_with_subcommand

v4.0.29

Compare Source

v4.0.28

Compare Source

Fixes
  • Fix wasm support which was broken in 4.0.27

v4.0.27

Compare Source

Features
  • Have Arg::value_parser accept Vec<impl Into<PossibleValue>>
  • Implement Display and FromStr for ColorChoice
Fixes
  • Remove soundness issue by switching from atty to is-terminal

v4.0.26

Compare Source

Fixes
  • (error) Fix typos in ContextKind::as_str

v4.0.25

Compare Source

Features
  • (error) Report available subcommands when required subcommand is missing

v4.0.24

Compare Source

Fixes
  • Avoid panic when printing an argument that isn't built

v4.0.23

Compare Source

Fixes
  • Don't panic on reporting invalid-long errors when followed by invalid UTF8
  • (help) Clarified argument to help subcommand

v4.0.22

Compare Source

Fixes
  • (help) Don't overflow into next-line-help early due to stale (pre-v4) padding calculations

v4.0.21

Compare Source

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)

v4.0.20

Compare Source

Fixes
  • (derive) Allow defaulted value parser for '()' fields

v4.0.19

Compare Source

Features
  • ColorChoice now implements ValueEnum

v4.0.18

Compare Source

Fixes
  • (derive) Allow #[command(skip)] to also work with enum variants with a value

v4.0.17

Compare Source

Fixes
  • Allow using Arg::last(true) with Arg::value_hint(ValueHint::CommandWithArguments)

v4.0.16

Compare Source

Fixes
  • Arg::exclusive(true) should not be exclusive with the argument's own ArgGroup

v4.0.15

Compare Source

Fixes
  • (error) Don't suggest -- when it doesn't help
  • (error) Be more consistent in quoting, punctuation, and indentation in errors

v4.0.14

Compare Source

Fixes
  • Only put ArgGroup in ArgMatches when explicitly specified, fixing derives handling of option-flattened fields (#​4375)

v4.0.13

Compare Source

Features
  • (derive) Allow () for fields to mean "don't read" (#​4371)

v4.0.12

Compare Source

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

v4.0.11

Compare Source

Fixes
  • (help) Fix wrapping calculations with ANSI escape codes

v4.0.10

Compare Source

Features

v4.0.9

Compare Source

Fixes
  • (derive) Process doc comments for #[command(subcommand)] like in clap v3

v4.0.8

Compare Source

Fixes
  • (derive) Remove a low-value assert preventing defaulting Help and Version actions

v4.0.7

Compare Source

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

v4.0.6

Compare Source

Features

v4.0.5

Compare Source

v4.0.4

Compare Source

Fixes
  • (error) Specialize the self-conflict error to look like clap v3

v4.0.3

Compare Source

Fixes
  • (parser) When overriding required(true), consider args that conflict with its group

v4.0.2

Compare Source

v4.0.1

Compare Source

Features
  • ColorChoice now implements ValueEnum

v4.0.0

Compare Source

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 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 <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
  • 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 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:

  • 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:

  1. Upgrade to v3 if you haven't already
  2. Add CLI tests (including example below), -h and --help output at a minimum (recommendation: trycmd for snapshot testing)
  3. If using Builder API: Explicitly set the arg.action(ArgAction::...) on each argument (StoreValue for options and IncOccurrences for flags)
  4. Run cargo check --features clap/deprecated and resolve all deprecation warnings
  5. Upgrade to v4
  6. 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
  1. Resolve compiler errors
  2. Resolve behavior changes (see "subtle changes" under BREAKING CHANGES)
  3. At your leisure: resolve new deprecation notices

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

Breaking Changes

Subtle changes (i.e. compiler won't catch):

  • arg! now sets one of (#​3795):
    • ArgAction::SetTrue, requiring ArgMatches::get_flag instead of ArgMatches::is_present
    • ArgAction::Count, requiring ArgMatches::get_count instead of ArgMatches::occurrences_of
    • ArgAction::Set, requiring ArgMatches::get_one instead of ArgMatches::value_of
    • ArgAction::Append, requiring ArgMatches::get_many instead of ArgMatches::values_of
  • ArgAction::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)
  • By default, an 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)
  • Removed lifetimes from 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)
  • Added default feature flags, help, usage and error-context, requiring adding them back in if default-features = false (#​4236)
  • (parser) Always fill in "" argument for external subcommands to make it easier to distinguish them from built-in commands (#​3263)
  • (parser) Short flags now have higher precedence than hyphen values with Arg::allow_hyphen_values, to be consistent with Command::allow_hyphen_values (#​4187)
  • (parser) Arg::value_terminator must be its own argument on the CLI rather than being in a delimited list (#​4025)
  • (help) Line wrapping of help is now behind the existing wrap_help feature flag, either enable it or hard code your wraps (#​4258)
  • (help) Make DeriveDisplayOrder the default and removed the setting. To sort help, set next_display_order(None) (#​2808)
  • (help) Subcommand display order respects Command::next_display_order instead of DeriveDisplayOrder and using its own initial display order value (#​2808)
  • (help) Subcommands are now listed before arguments. To get the old behavior, see Command::help_template (#​4132)
  • (help) Help headings are now title cased, making any user-provided help headings inconsistent. To get the old behavior, see Command::help_template, Arg::help_heading, and Command::subcommand_help_heading (#​4132)
  • (help) "Command" is used as the section heading for subcommands and COMMAND for the value name. To get the old behavior, see Command::subcommand_help_heading and Arg::subcommand_value_name (#​4132, #​4155)
  • (help) Whitespace in help output is now trimmed to ensure consistency regardless of how well a template matches the users needs. (#​4132, #​4156)
  • (help) name/version/author are removed by default from help output. To get the old behavior, see Command::help_template. (#​4132, #​4160)
  • (help) Indentation for second-line usage changed. (#​4132, #​4188)
  • (env) Parse --help and --version like any ArgAction::SetTrue flag (#​3776)
  • (derive) Leave Arg::id as verbatim casing, requiring updating of string references to other args like in conflicts_with or requires (#​3282)
  • (derive) Doc comments for ValueEnum variants will now show up in --help (#​3312)
  • (derive) When deriving Args, and ArgGroup is created using the type's name, reserving it for future use (#​2621, #​4209)
  • (derive) next_help_heading can now leak out of a #[clap(flatten)], like all other command settings (#​4222)

Easier to catch changes:

  • Looking up a group in ArgMatches now returns the arg Ids, rather than the values to reduce overhead and offer more flexibility. (#​4072)
  • Changed 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)
    • Does not check default or env values, only what the user explicitly passes in (#​4025)
    • No longer terminates on delimited values (#​4025)
  • Replace Arg::min_values (across all occurrences) with Arg::num_args(N..) (per occurrence) to reduce confusion over different value count APIs (#​4023)
  • Replace Arg::max_values (across all occurrences) with Arg::num_args(1..=M) (per occurrence) to reduce confusion over different value count APIs (#​4023)
  • Replace 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)
  • Replace 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 APIs
  • Remove Arg::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)
  • Changed Arg::requires_ifs and Arg::default_value*_ifs* to taking an ArgPredicate, removing ambiguity with None when accepting owned and borrowed types (#​4084)
  • Removed PartialEq and Eq from Command so we could change external subcommands to use a ValueParser (#​3990)
  • Various 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 module
  • ErrorKind::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)
  • Changed the default type of allow_external_subcommands from String to OsString as that is less likely to cause bugs in user applications (#​3990)
  • (help) Command::render_usage now returns a StyledStr (#​4248)
  • (derive) Changed the default for arguments from parse to value_parser, removing parse support (#​3827, #​3981)
    • #[clap(value_parser)] and #[clap(action)] are now redundant
  • (derive) subcommand_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)
  • (derive) Remove 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)
  • (parser) Assert when the CLI looksup an unknown args when external subcommand support is enabled to help catch bugs (#​3703)
  • (assert) Sometimes Arg::default_missing_value didn't require num_args(0..=N), now it does (#​4023)
  • (assert) Leading dashes in Arg::long are no longer allowed (#​3691)
  • (assert) Disallow more value_names than num_args (#​2695)
  • (assert) Always enforce that version is specified when the ArgAction::Version is used
  • (assert) Add missing #[track_caller]s to make it easier to debug asserts
  • (assert) Ensure overrides_with IDs are valid
  • (assert) Ensure no self-overrides_with now that Actions replace it
  • (assert) Ensure subcommand names are not duplicated
  • (assert) Assert on mut_arg receiving an invalid arg ID or mut_subcommand receiving an invalid command name
Compatibility

MSRV 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 thing
  • Arg::requires_all in favor of Arg::requires_ifs now that it takes an ArgPredicate to avoid having multiple ways of doing the same thing
  • Arg::number_of_values in favor of Arg::num_args to clarify semantic differences
  • default_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::env
  • Command::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)
  • (help) Deprecated Command::write_help and Command::write_long_help in favor of Command::render_help and Command::render_long_help (#​4248)
  • (derive) 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)
  • (derive) #[clap(value_parser)] and #[clap(action)] defaulted attributes (its the default) (#​3976)

Behavior Changes

  • (help) With wrap_help feature, if the terminal size cannot be determined, LINES and COLUMNS variables are used (#​4186)
Features
  • Arg::num_args now accepts ranges, allowing setting both the minimum and maximum number of values per occurrence (#​2688, #​4023)
  • Allow non-bool value_parsers for ArgAction::SetTrue / ArgAction::SetFalse (#​4092)
  • Add From<&OsStr>, From<OsString>, From<&str>, and From<String> to value_parser! (#​4257)
  • Allow resetting most builder methods
  • Can now pass runtime generated data to Command, Arg, ArgGroup, PossibleValue, etc without managing lifetimes with the string feature flag (#​2150, #​4223)
  • New default error-context, help and usage feature flags that can be turned off for smaller binaries (#​4236)
  • Added StyledStr::ansi() to Display with ANSI escape codes (#​4248)
  • (error) Error::apply for changing the formatter for dropping binary size (#​4111)
  • (error) Error::renderfor formatting the error into a StyledStr
  • (help) Show PossibleValue::help in long help (--help) (#​3312)
  • (help) New {tab} variable for Command::help_template (#​4161)
  • (help) Command::render_help and Command::render_long_help for formatting the error into a StyledStr (#​3873, #​4248)
  • (help) Command::render_usage now returns a StyledStr (#​4248)
Fixes
  • Verify required is not used with conditional required settings (#​3660)
  • Replaced 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)
  • Allow OsStrs for Arg::{required_if_eq,required_if_eq_any,required_if_eq_all} (#​4084)
  • (help) With wrap_help feature, if the terminal size cannot be determined, LINES and COLUMNS variables are used (#​4186)
  • (help) Use Command::display_name in the help title rather than Command::bin_name
  • (help) Show when a flag is ArgAction::Count by adding an ... (#​4003)
  • (help) Use a more neutral palette for coloring (#​4132, #​4117)
  • (help) Don't rely on ALL CAPS for help headers (#​4132, #​4123)
  • (help) List subcommands first, focusing the emphasis on them (#​4132, #​4125)
  • (help) Do not include global args in cmd help help (#​4131)
  • (help) Use [positional] in list when relevant (#​4144)
  • (help) Show all [positional] in usage (#​4151)
  • (help) Polish up subcommands by referring to them as commands (#​4132, #​4155)
  • (help) Trim extra whitespace to avoid artifacts from different uses of templates (#​4132, #​4156)
  • (help) Hint to the user the difference between -h / --help when applicable (#​4132, #​4159)
  • (help) Shorten help by eliding name/version/author (#​4132, #​4160)
  • (help) When short help is long enough to activate next_line_help, don't add blank lines (#​4132, #​4190)
  • (help) Make help output more dense (reducing horizontal whitespace) (#​4132, #​4192)
  • (help) Separate subcommand flags with "," like option flags (#​4232, #​4235)
  • (help) Quote the suggested help flag (#​4220)
  • (version) Use Command::display_name rather than Command::bin_name (#​3966)
  • (parser) Always fill in "" argument for external subcommands (#​3263)
  • (parser) Short flags now have higher precedence than hyphen values with Arg::allow_hyphen_values, like Command::allow_hyphen_values (#​4187)
  • (parser) Prefer InvalidSubcommand over UnknownArgument in more cases (#​4219)
  • (derive) Detect escaped external subcommands that look like built-in subcommands (#​3703)
  • (derive) Leave Arg::id as verbatim casing (#​3282)
  • (derive) Default to #[clap(value_parser, action)] instead of #[clap(parse)] (#​3827)

v3.2.25

Compare Source

[3.2.25] - 2023-04-27

Fixes
  • (derive) Resolve warnings in generated code

v3.2.24

Compare Source

[3.2.24] - 2023-04-25

Fixes
  • (derive) Resolve warnings in generated code

v3.2.23

Compare Source

[3.2.23] - 2022-10-24

Fixes
  • Upgrade to textwrap 0.16

v3.2.22

Compare Source

[3.2.22] - 2022-09-16

Fixes
  • Unify dependencies on terminal_size to the 0.2 release

v3.2.21

Compare Source

[3.2.21] - 2022-09-12

Features
  • TypedValueParser::map to allow reusing existing value parsers for other purposes

v3.2.20

Compare Source

[3.2.20] - 2022-09-02

Features
  • ArgMatches::get_count help for ArgAction::Count
  • ArgMatches::get_flag help for ArgAction::SetTrue / ArgAction::SetFalse

v3.2.19

Compare Source

[3.2.19] - 2022-08-30

Fixes
  • (help) Ensure required arguments for parent commands aren't shown in their subcommands when using args_conflicts_with_subcommand

v3.2.18

Compare Source

Fixes
  • (help) Command::print_help now respects Command::colored_help
  • (derive) Improved error messages

v3.2.17

Compare Source

Fixes
  • (derive) Expose #[clap(id = ...)] attribute to match Arg's latest API

v3.2.16

Compare Source

Fixes
  • Ensure required arguments appear in errors when they are also members of a group (#​4004)

v3.2.15

Compare Source

Features
  • (derive) New default_values_t and default_values_os_t attributes

v3.2.14

Compare Source

Fixes
  • A multiple_values positional followed by another positional now works with multiple flags

v3.2.13

Compare Source

Documentation
  • Pulled in tutorials, cookbook, and derive reference into rustdoc

v3.2.12

Compare Source

Fixes
  • Allow an arg to declare a conflict with a group

v3.2.11

Compare Source

Features
  • Added Arg::get_all_short_aliaes and Arg::get_all_aliases

v3.2.10

Compare Source

Fixes
  • Loosen lifetime on Command::mut_subcommand

v3.2.8

Compare Source

Features
  • Added Command::mut_subcommand to mirror Command::mut_arg

v3.2.7

Compare Source

Fixes
  • Global arguments should override env-sourced arguments

v3.2.6

Compare Source

Fixes
  • Don't panic when parsing --=

v3.2.5

Compare Source

Fixes
  • (derive) Fix regression with #[clap(default_value_os_t ...)] introduced in v3.2.3

v3.2.4

Compare Source

Fixes
  • (derive) Provide more clearer deprecation messages for #[clap(parse)] attribute (#​3832)

v3.2.3

Compare Source

Fixes
  • (derive) Fix regression with #[clap(default_value_os_t ...)] introduced in v3.2.3

v3.2.2

Compare Source

Fixes
  • (derive) Improve the highlighted code for deprecation warnings

gated behind unstable-v4

  • (derive) Default to #[clap(value_parser, action)] instead of #[clap(parse)] (#​3827)

v3.2.1

Compare Source

Fixes
  • (help) Command::print_help now respects Command::colored_help
  • (derive) Improved error messages

v3.2.0

Compare Source

Compatibility

MSRV is now 1.56.0 (#​3732)

Behavior

  • Defaults no longer satisfy required and its variants (#​3793)
  • When misusing ArgMatches::value_of and friends, debug asserts were turned into panics

Moving (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)
  • (derive) #[clap(parse(...))] replaced with: (#​3589, #​3794)
    • For default parsers (no 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.
    • For #[clap(parse(from_flag))] replaced with #[clap(action = ArgAction::SetTrue)] (#​3794)
    • For #[clap(parse(from_occurrences))] replaced with #[clap(action = ArgAction::Count)] though the field's type must be u8 (#​3794)
    • For #[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).
    • For #[clap(parse(try_from_str = ...)], replace it with #[clap(value_parser = ...)]
    • For most other cases, a type implementing TypedValueParser will be needed and specify it with #[clap(value_parser = ...)]
Features
  • Parsed, typed arguments via Arg::value_parser / ArgMatches::{get_one,get_many} (#​2683, #​3732)
    • Several built-in TypedValueParsers available with an API open for expansion
    • value_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 values
    • All ArgMatches getters do not assume required arguments (#​2505)
    • Add ArgMatches::remove_* variants to transfer ownership
    • Add ArgMatches::try_* variants to avoid panics for developer errors (#​3621)
    • Add a get_raw to access the underlying OsStrs
    • PathBuf value parsers imply ValueHint::AnyPath for completions (#​3732)
  • Explicit control over parsing via Arg::action (#​3774)
    • ArgAction::StoreValue: existing takes_value(true) behavior
    • ArgAction::IncOccurrences: existing takes_value(false) behavior
    • ArgAction::Help: existing --help behavior
    • ArgAction::Version: existing --version behavior
    • ArgAction::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)
      • Implies Arg::default_value("false") (#​3786)
      • Parses Arg::env via Arg::value_parser
    • ArgAction::SetFalse: Treat --flag as --flag=false (#​3775)
      • Implies Arg::default_value("true") (#​3786)
      • Parses Arg::env via Arg::value_parser
    • ArgAction::Count: Treat --flag --flag --flag as --flag=1 --flag=2 --flag=3 (#​3775)
      • Implies Arg::default_value("0") (#​3786)
      • Parses Arg::env via Arg::value_parser
  • (derive) Opt-in to new Arg::value_parser / Arg::action with either #[clap(value_parser)] (#​3589, #​3742) / #[clap(action)] attributes (#​3794)
    • Default ValueParser is determined by value_parser! (#​3199, #​3496)
    • Default 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} API
Fixes
  • Don't correct argument id in default_value_ifs_os(#​3815)

parser

  • Set ArgMatches::value_source and ArgMatches::occurrences_of for external subcommands (#​3732)
  • Use value delimiter for Arg::default_missing_values (#​3761, #​3765)
  • SplitArg::default_value / Arg::env on value delimiters independent of whether -- was used (#​3765)
  • Allow applying defaults to flags (#​3294, 3775)
  • Defaults no longer satisfy required and its variants (#​3793)

v3.1.18

Compare Source

Fixes
  • Fix deprecated arg_enum! for users migrating to clap3 (#​3717)
  • Verify all required_unless_present_all arguments exist
  • Verify group members exist before processing group members (#​3711)
  • (help) Use ... when not enough value_names are supplied

gated behind unstable-v4

  • Verify required is not used with conditional required settings (#​3660)
  • Disallow more value_names than number_of_values (#​2695)
  • (parser) Assert on unknown args when using external subcommands (#​3703)
  • (parser) Always fill in "" argument for external subcommands (#​3263)
  • (derive) Detect escaped external subcommands that look like built-in subcommands (#​3703)
  • (derive) Leave Arg::id as verbatim casing (#​3282)

v3.1.17

Compare Source

Fixes
  • Allow value names for arg! macro to have dashes when quoted, like longs

v3.1.16

Compare Source

Fixes
  • (parser) Arg::exclusive overrides Arg::required, like other conflicts
  • (error) Don't duplicate arguments in usage
  • (error) Don't show hidden arguments in conflict error usage
  • (help) New help_template variable {name} to fix problems with {bin}
  • (help) Don't wrap URLs

gated behind unstable-v4

  • Leading dashes in Arg::long are no longer allowed
  • (help) Use Command::display_name in the help title rather than Command::bin_name

v3.1.15

Compare Source

Fixes
  • (error) Render actual usage for unrecognized subcommands
  • (multicall) Improve bad command error
  • (multicall) Always require a multicall command
  • (multicall) Disallow arguments on multicall parent command
  • (multicall) More consistent with rest of clap errors

v3.1.14

Compare Source

Fixes
  • Panic when calling Command::build with a required positional argument nested several layers in subcommands

v3.1.13

Compare Source

Fixes
  • Help subcommand and Command::write_help now report required arguments in usage in more circumstances
  • Unknown subcommand for help subcommand flag now reports an error with more context
  • More details reported when using debug feature
  • Allow disabling color feature with debug feature enabled

v3.1.12

Compare Source

Fixes
  • Regression in 3.1.11 where the (output) streams were crossed

v3.1.11

Compare Source

Fixes
  • Implied conflicts override Arg::required, making the behavior consistent with how we calculate conflicts for error reporting
  • Members of a mutually exclusive ArgGroup override Arg::required, making the behavior consistent with how we calculate conflicts for error reporting
  • Arg::overrides_with always override Arg::required, not just when the parser processes an override

v3.1.10

Compare Source

Features
  • Expose Command::build for custom help generation or other command introspection needs

v3.1.9

Compare Source

Fixes
  • Pin the clap_derive version so a compatible version is always used with clap

v3.1.8

Compare Source

Fixes
  • Add Debug impls to more types

v3.1.7

Compare Source

Fixes
  • (derive) Abort, rather than ignore, when deriving ArgEnum with non-unit unskipped variants

v3.1.6

Compare Source

Fixes
  • Don't panic when validating delimited defaults (#​3541)
  • Make it clearer that cargo feature is needed
  • Documentation improvements

v3.1.5

Compare Source

Fixes
  • Dependency upgrade

v3.1.4

Compare Source

Features
  • (help) Show PossibleValue::help in long help (--help) (gated behind unstable-v4) (#​3312)

v3.1.3

Compare Source

Fixes
  • Don't panic when validating delimited defaults (#​3514)

v3.1.2

Compare Source

Fixes
  • (derive) Allow other attribute with a subcommand that has subcommands
Documentation
  • (examples) List example topics
  • (derive) Clarify syntax and relation to builder API

v3.1.1

Compare Source

Fixes
  • Fix deprecated arg_enum! for users migrating to clap3 (#​3717)
  • Verify all required_unless_present_all arguments exist
  • Verify group members exist before processing group members (#​3711)
  • (help) Use ... when not enough value_names are supplied

gated behind unstable-v4

  • Verify required is not used with conditional required settings (#​3660)
  • Disallow more value_names than number_of_values (#​2695)
  • (parser) Assert on unknown args when using external subcommands (#​3703)
  • (parser) Always fill in "" argument for external subcommands (#​3263)
  • (derive) Detect escaped external subcommands that look like built-in subcommands (#​3703)
  • (derive) Leave Arg::id as verbatim casing (#​3282)

v3.1.0

Compare Source

Compatibility

Changes in behavior of note that are not guaranteed to be compatible across releases:

  • (help) help subcommand shows long help like --help, rather than short help (-h), deprecated clap::AppSettings::UseLongFormatForHelpSubcommand (#​3440)
  • (help) Pacman-style subcommands are now ordered the same as usage errors (#​3470)
  • (help) Pacman-style subcommands use standard alternate syntax in usage (#​3470)
Deprecations
  • clap::Command is now preferred over clap::App (#​3089 in #​3472)
    • clap::command! is now preferred over clap::app_from_crate (#​3089 in #​3474)
    • clap::CommandFactory::command is now preferred over clap::IntoApp::into_app (#​3089 in #​3473)
  • (help) help subcommand shows long help like --help, rather than short help (-h), deprecated clap::AppSettings::UseLongFormatForHelpSubcommand (#​3440)
  • (error) Deprecate clap::AppSettings::WaitOnError, leaving it to the user to implement
  • (validation) clap::Command::subcommand_required(true).arg_required_else_help(true) is now preferred over clap::AppSettings::SubcommandRequiredElseHelp (#​3280)
  • (builder) clap::AppSettings are nearly all deprecated and replaced with builder methods and getters (#​2717)
  • (builder) clap::ArgSettings is deprecated and replaced with builder methods and getters (#​2717)
  • (builder) clap::Arg::id and clap::ArgGroup::id are now preferred over clap::Arg::name and clap::ArgGroup::name (#​3335)
  • (help) clap::Command::next_help_heading is now preferred over clap::Command::help_heading (#​1807, #​1553)
  • (error) clap::error::ErrorKind is now preferred over clap::ErrorKind (#​3395)
  • (error) clap::Error::kind() is now preferred over clap::Error::kind
  • (error) clap::Error::context() is now preferred over clap::Error::info (#​2628)

Note: All items deprecated in 3.0.0 are now hidden in the documentation. (#​3458)

Features
  • (matches) Add clap::ArgMatches::value_source to determine what insert the value (#​1345)
  • (help) Override derived display order with clap::Command::next_display_order (#​1807)
  • (error) Show possible values when an argument doesn't have a value (#​3320)
  • (error) New clap::Error::context API to open the door for fully-custom error messages (#​2628)
    • (error) clap::error::ErrorKind now implements Display
Fixes
  • (builder) Some functions were renamed for consistency and fixing spelling issues
  • (builder) Allow clap::Command::color to override previous calls (#​3449)
  • (parse) Propagate globals with multiple subcommands (#​3428)
  • (validation) Give ArgRequiredElseHelp precedence over SubcommandRequired (#​3456)
  • (validation) Default values no longer count as "present" for conflicts, requires, clap::Command::arg_required_else_help, etc (#​3076, #​1264)
  • (assert) Report invalid defaults (#​3202)
  • (help) Clarify how to handle -h conflicts (#​3403)
  • (help) Make it easier to debug the addition of help flags (#​3425)
  • (help) Pacman-style subcommands are now separated with spaces (#​3470)
  • (help) Pacman-style subcommands are now ordered the same as usage errors (#​3470)
  • (help) Pacman-style subcommands use standard alternate syntax in usage (#​3470)
  • (error) Be consistent in showing of required attributes between errors / usage (#​3390)
  • (error) Show user's order of possible values, like in --help (#​1549)
  • (error) Allow customizing error type in clap::error::Result (#​3395)
Performance
  • (error) Reduced stack size of clap::Error (#​3395)
Documentation
  • (builder) Correct data take accepted for clap::Arg::validator
  • (derive) Clarify parse attribute
  • (tutorial) Demonstrate custom parsing
  • (example) Consistently list out required feature flags (#​3448)

v3.0.14

Compare Source

Features
  • Added ArgMatches::args_present() to check if any args are present
  • Added Error::kind() as we work to deprecate direct member access for Error
  • Added App::get_version
  • Added App::get_long_version
  • Added App::get_author
  • Added App::get_subcommand_help_heading
  • Added App::get_subcommand_value_name
  • Added App::get_after_help
  • Added App::get_after_long_help
Performance
  • Misc binary size reductions

v3.0.13

Compare Source

Fixes
  • Show optional flag values wrapped in []

v3.0.12

Compare Source

Features
  • (derive) Support for default_value_os_t

v3.0.11

Compare Source

Fixes
  • Ensure conflicts work when they target a group with a default value

v3.0.10

Compare Source

Fixes
  • Resolve panic! from v3.0.8 when using global_setting(PropagateVersion).

v3.0.9

Compare Source

Features
  • Added App::find_subcommand_mut

v3.0.8

Compare Source

Fixes
  • Respected DisableColoredHelp on cmd help help
  • Provide a little more context when completing arguments for cmd help
  • Provide more context for some asserts
  • Small documentation improvements

v3.0.7

Compare Source

Fixes
  • Shift more asserts from parsing to App building (ie will now run in App::debug_assert)

derive

  • Documentation fixes

v3.0.6

Compare Source

Fixes

derive

  • Don't assume user does use clap::ArgEnum (#​3277)
  • Documentation fixes

v3.0.5

Compare Source

Fixes

docs:

  • Cleaned up code blocks in tutorials (#​3261)
  • Clean up quotes in ArgMatches asserts
  • List correct replacement for deprecated Parser::from_clap (#​3257)

v3.0.4

Compare Source

Features
  • For very limited cases, like cargo, expose ArgMatches::is_valid_arg to avoid panicing on undefined arguments

v3.0.3

Compare Source

Fixes
  • Specify cause of debug assert failure

v3.0.2

Compare Source

Fixes
  • Ignore Last when checking hyphen values (see #​3249 for details)
  • Help catch bugs with #[must_use]

v3.0.1

Compare Source

Features
  • Added ArgMatches::args_present() to check if any args are present
  • Added Error::kind() as we work to deprecate direct member access for Error
  • Added App::get_version
  • Added App::get_long_version
  • Added App::get_author
  • Added App::get_subcommand_help_heading
  • Added App::get_subcommand_value_name
  • Added App::get_after_help
  • Added App::get_after_long_help
Performance
  • Misc binary size reductions

v3.0.0

Compare Source

Note: clap v3 has been in development for several years and has changed
hands multiple times. Unfortunately, our changelog might be incomplete,
whether in changes or their motivation.

Highlights

A special thanks to the maintainers, contributors, beta users, and sponsors who
have helped along this journey, especially kbknapp.

StructOpt Integration

StructOpt provides a serde-like declarative
approach to defining your parser. The main benefits we've seen so far from integrating are:

  • Tighter feedback between the design of clap and the derives
  • More universal traits. Crates exist for common CLI patterns
    (example)
    and we've re-designed the StructOpt traits so crates built on clap3 can be
    reused not just with other derives but also people using the builder API.
    People can even hand implement these so people using the builder API won't
    have the pay the cost for derives.

Custom Help Headings

Previously, clap automatically grouped arguments in the help as either
ARGS, FLAGS, OPTIONS, and SUBCOMMANDS.

You can now override the default group with Arg::help_heading and
App::subcommand_help_heading. To apply a heading to a series of arguments,
you can set App::help_heading.

Deprecations

While a lot of deprecations have been added to clean up the API (overloaded
meaning of Arg::multiple) or make things more consistent, some particular
highlights are:

Migrating

From clap v2

  1. Add CLI tests, -h and --help output at a minimum (recommendation: trycmd for snapshot testing)
  2. Update your dependency
    1. If you use no-default-features: add the std feature
  3. Resolve compiler errors
  4. Resolve behavior changes
    1. Refactor your App creation to a function and add a test similar to the one below, resolving any of its assertions
    2. Look over the "subtle changes" under BREAKING CHANGES
    3. If using builder: test your application under various circumstances to see if ArgMatches asserts regarding AllowInvalidUtf8.
  5. At your leisure: resolve deprecation notices

Example test:

fn app() -> clap::App<'static> {
    ...
}

#[test]
fn verify_app() {
    app().debug_assert();
}

From structopt 0.3.25

  1. Add CLI tests, -h and --help output at a minimum (recommendation: trycmd for snapshot testing)
  2. Replace your dependency from structopt = "..." to clap = { version = "3.0", features = ["derive"] }
    1. If you use no-default-features: add the std feature
  3. Resolve compiler errors, including
    1. Update your use statements from structopt and structopt::clap to clap
  4. Resolve behavior changes
    1. Add a test similar to the one below, resolving any of its assertions
    2. Look over the "subtle changes" under BREAKING CHANGES
  5. At your leisure: resolve deprecation notices

Example test:


#[derive(clap::StructOpt)]
struct Args {
    ...
}

#[test]
fn verify_app() {
    use clap::IntoApp;
    Args::into_app().debug_assert()
}

From clap v3.0.0-beta.5

  1. Add CLI tests, -h and --help output at a minimum (recommendation: trycmd for snapshot testing)
  2. Update your dependency
    1. Add in derive, env, cargo, or unicode feature flags as needed
  3. Resolve compiler errors
    1. If you use yaml, clap_app!, or usage parser: revert any changes you made for clap3
    2. Change Arg::about Arg::long_about back to help and long_help and change PossibleValue::about to help (clap-rs/clap#3075)
    3. Change AppSettings::HelpRequired to AppSettings::HelpExpected
    4. Change PossibleValue::hidden to PossibleValue::hide
    5. Change App::subcommand_placeholder to App::subcommand_value_name / App::subcommand_help_heading
  4. Resolve behavior changes
    1. Add the above listed test appropriate for your application and resolve any problems it reports
    2. If using derive: see the structopt breaking changes section for Vec changes
    3. If using builder: test your application under various circumstances to see if ArgMatches asserts regarding AllowInvalidUtf8.
  5. At your leisure: resolve deprecation notices
BREAKING CHANGES

From clap 2

Subtle changes (i.e. compiler won't catch):

  • AppSettings::UnifiedHelpMessage is now default behaviour
    • {flags} and {unified} will assert if present in App::help_template
    • See clap-rs/clap#2807
  • AppSettings::EnableColoredHelp is now the default behavior but can be
    opted-out with AppSettings::DisableColoredHelp
    (clap-rs/clap#2806)
  • App::override_usage no longer implies a leading \t, allowing multi lined usages
  • Arg::require_equals no longer implies ArgSettings::ForbidEmptyValues (#​2233)
  • Arg::require_delimiter no longer implies ArgSettings::TakesValue and ArgSettings::UseValueDelimiter (#​2233)
  • Arg::env, Arg::env_os, Arg::last, Arg::require_equals, Arg::allow_hyphen_values,
    Arg::hide_possible_values, Arg::hide_default_value, Arg::hide_env_values,
    Arg::case_insensitive and Arg::multiple_values no longer imply ArgSettings::TakesValue (#​2233)
  • ArgMatches::is_present no longer checks subcommand names
  • Some env variable values are now considered false for flags, not just "not-present" (clap-rs/clap#2539)
  • Changed ...s meaning in usage parser. Before, it always meant multiple which is still true for --option [val].... Now [name]... --option [val] results in ArgSettings::MultipleOccurrences.
  • Usage exit code changed from 1 to 2 (clap-rs/clap#1327)
  • Reject --foo=bar when takes_value(false) (clap-rs/clap#1543)
  • No longer accept an arbitrary number of - for long arguments (-----long)

Easier to catch changes:

  • When using no-default-features, you now have to specify the std feature (reserved for future work)
  • Gated env support behind env feature flag
    • Impacts Arg::env, Arg::env_os, Arg::hide_env_values, ArgSettings::HideEnvValues
    • See clap-rs/clap#2694
  • Gated crate information behind cargo feature flag
    • Impacts crate_name!, crate_version!, crate_authors!, crate_description!, app_from_crate!
  • AppSettings::StrictUtf8 is now default behaviour and asserts if
    AppSettings::AllowInvalidUtf8ForExternalSubcommands and
    ArgSettings::AllowInvalidUtf8 and ArgMatches::value_of_os aren't used
    together
  • Arg::short and Arg::value_delimiter now take a char instead of a &str
  • ArgMatches panics on unknown arguments
  • Removed VersionlessSubcommands, making it the default (see clap-rs/clap#2812)
  • Completion generation has been split out into clap_complete.
  • Removed ArgSettings::EmptyValues in favor of ArgSettings::ForbidEmptyValues
  • Validator signatures have been loosed:
    • Arg::validator now takes first argument as Fn(&str) -> Result<O, E: ToString> instead of
      Fn(String) -> Result<(), String>
    • Arg::validator_os now takes first argument as Fn(&OsStr) -> Result<O, OsString> instead of
      Fn(&OsStr) -> Result<(), OsString>
  • Arg::value_name now sets, rather than appends (see clap-rs/clap#2634)
  • Upgrade yaml-rust from 0.3 to 0.4
  • Replaced ArgGroup::from(BTreeMap) to ArgGroup::from(yaml)
  • Replaced ArgMatches::usage with App::generate_usage
  • Replaced Arg::settings with Arg::setting(Setting1 | Setting2)
  • App and Arg now need only one lifetime
  • Removed deprecated App::with_defaults, replaced with app_from_crate
  • Removed deprecated AppSettings::PropagateGlobalValuesDown (now the default)
  • Some App functions, like App::write_help now take &mut self instead of &self
  • Error::message is now private, use Error::to_string
  • Arg::default_value_if, Arg::default_value_if_os, Arg::default_value_ifs,
    Arg::default_value_ifs_os now takes the default value parameter as an option (clap-rs/clap#1406)
  • Changed App::print_help & App::print_long_help to now return std::io::Result
  • Changed App::write_help & App::write_long_help to now return std::io::Result
  • Changed Arg::index, Arg::number_of_values, Arg::min_values, Arg::max_values to taking usize instead of u64
  • Changed Error::info to type Vec<String> instead of Option<Vec<String>>
  • Changed ArgMatches::subcommand to now return Option<(&str, &ArgMatches)>
  • Renamed ErrorKind::MissingArgumentOrSubcommand to ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand
  • Renamed ErrorKind::HelpDisplayed to ErrorKind::DisplayHelp
  • Renamed ErrorKind::VersionDisplayed to ErrorKind::DisplayVersion
  • Added #[non_exhaustive] to clap::{ValueHint, ErrorKind, AppSettings, ArgSettings} (clap-rs/clap#3167)

From structopt 0.3.25

  • By default, the App isn't initialized with crate information anymore. Now opt-in via #[clap(author)], #[clap(about)], #[clap(version)] (clap-rs/clap#3034)
  • #[clap(default_value)] is replaced with #[clap(default_value_t)] (clap-rs/clap#1694)
  • Subcommands nested under subcommands now needs a #[clap(subcommand)] attribute (clap-rs/clap#2587)
  • Vec<_> and Option<Vec<_>> have changed from multiple to multiple_occurrences

On top of the clap 2 changes

Performance

From clap 2

  • Split out non-default unicode feature flag for faster builds and smaller binaries for ASCII-only CLIs.
  • Split out non-default env feature flag for faster builds and smaller binaries.
Features

From clap 2

  • Integration of structopt::StructOpt via clap::Parser (requires derive feature flag)

  • Custom help headings

    • App::help_heading (apply to all future args)
    • Arg::help_heading (apply to current arg)
    • App::subcommand_help_heading along with App::subcommand_value_name (apply to subcommands)
    • See clap-rs/clap#805
    • AppSettings::UnifiedHelpMessage is now default behaviour (clap-rs/clap#2807)
  • Deriving of ArgEnum for generating Arg::possible_values (requires derive feature flag)

  • Disable built-in help/version behavior with AppSettings::NoAutoHelp and AppSettings::NoAutoVersion

  • Change an existing arg with new builder method mut_arg (particularly helpful for --help and --version)

  • Provide extra context in long help messages (--help) with before_long_help and after_long_help (clap-rs/clap#1903)

  • Detect missing help descriptions via debug asserts by enabling AppSettings::HelpExpected

  • Aliases for short flags (clap-rs/clap#1896)

  • Validate UTF-8 values, rather than panicing during ArgMatches::value_of thanks to AppSettings::AllowInvalidUtf8ForExternalSubcommands and ArgSettings::AllowInvalidUtf8

    • Debug builds will assert when the ArgMatches calls do not match the UTF-8 setting.
    • See clap-rs/clap#751
  • clap::PossibleValue to allow

  • Allow arguments to conflict with all others via Arg::exclusive (clap-rs/clap#1583)

  • Validate arguments with a regex (required regex feature flag)

  • Arg::default_missing_value for cases like --color[=<WHEN>] (clap-rs/clap#1587)

  • clap::App::color / clap::ColorChoice to specify color setting for the app

  • Custom error reporting with App::error

  • App::debug_assert test helper

  • Replace Arg::multiple(bool) with Arg::multiple_values / Arg::multiple_occurrences

    • Positionals can be either
  • Added support for flag subcommands like pacman (clap-rs/clap#1361)

  • Partial parsing via AppSettings::IgnoreErrors (clap-rs/clap#1880)

  • Enable cmd help to print long help (--help instead of -h) with AppSettings::UseLongFormatForHelpSubcommand (clap-rs/clap#2435)

  • Allow long arg abbreviations like we do with subcommands via AppSettings::InferLongArgs (clap-rs/clap#2435)

  • Detect subcommands among positional arguments with AppSettings::SubcommandPrecedenceOverArg

  • Give completion scripts hints with Arg::value_hint (clap-rs/clap#1793)

  • Allow unsetting defaults with

  • Arg::default_value_if, Arg::default_value_if_os, Arg::default_value_ifs,
    Arg::default_value_ifs_os (clap-rs/clap#1406)

  • Interpret some env variable values as false for flags, in addition to "not-present" (clap-rs/clap#2539)

    • n, no, f, false, off, 0
  • Added arg! macro for creating an Arg from a compile-time usage parser

  • (Experimental) Busybox-like multi-call support

    • See AppSettings::Multicall behind unstable-multicall feature flag
    • See clap-rs/clap#1120
  • (Experimental) Alias an argument to anything group of arguments

    • See App::replace behind unstable-replace feature flag
    • See clap-rs#1603
  • (Experimental) Grouping of multiple values within multiple occurrences

    • See ArgMatches::grouped_values_of behind unstable-grouped feature flag
    • See clap-rs/clap#1026

From structopt 0.3.25

  • Allow defaulting with native types via new default_value_t [= <expr>] attribute (clap-rs/clap#1694)
  • New update API
  • New arg_enum attribute for integrating with ArgEnum trait

On top of the clap 2 changes

Fixes

From clap 2

  • Correctly handle colored output on Windows
  • Only generate version flags when App::version, App::long_version are set
    (see clap-rs/clap#2812)
  • General completion script improvements
  • Limited default help text wrapping to 100 when wrap_help feature is not enabled
  • Be more specific than Arg::multiple with Arg::multiple_values and Arg::multiple_occurrences
  • app_from_crate! defaults to separating multiple authors with ", "
  • Ensure all examples work
  • IgnoreCase is now unicode aware (requires unicode feature flag)
  • Always respect ColorChoice::Never, even if that means we skip colors in some cases
  • ArgMatches panics on unknown arguments
  • Gracefully handle empty authors field in Cargo.toml with app_from_crate
  • Do not show --help in cmd help with DisableHelpFlag (clap-rs/clap#3169)
  • Do not show --help in cmd help help that doesn't work (clap-rs/clap#3169)

From structopt 0.3.25

  • Support SubcommandsNegateReqs by allowing required Option<_>s (clap-rs/clap#2255)
  • Infer AllowInvalidUtf8 based on parser (clap-rs/clap#751)
  • Gracefully handle empty authors field in Cargo.toml
  • Don't panic with default_value_os but treat it like default_value (clap-rs/clap#3031)
  • When using flatten and subcommand, ensure our doc comment always overrides the nested container's doc comment, whether it has only about or about and long_about (clap-rs/clap#3175)

On top of the clap 2 changes

Minimum Required Rust
  • As of this release, clap requires rustc 1.54.0 or greater.

v2.34.0

Compare Source

  • Updates to Rust 2018 edition and bumps the MSRV to Rust 1.46

v2.33.4

Compare Source

Bug Fixes
  • prevents panic: swallows broken pipe errors on error output (7a729bc4)

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Renovate Bot.

This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap](https://github.com/clap-rs/clap) | dependencies | major | `2.33` -> `4.0` | --- ### Release Notes <details> <summary>clap-rs/clap (clap)</summary> ### [`v4.5.51`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4551---2025-10-29) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.50...v4.5.51) ##### Fixes - *(help)* Correctly calculate padding for short flags that take a value - *(help)* Don't panic on short flags using `ArgAction::Count` ### [`v4.5.50`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4550---2025-10-20) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.49...v4.5.50) ##### Features - Accept `Cow` where `String` and `&str` are accepted ### [`v4.5.49`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4549---2025-10-13) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.48...v4.5.49) ##### Fixes - *(help)* Correctly wrap when ANSI escape codes are present ### [`v4.5.48`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4548---2025-09-19) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.47...v4.5.48) ##### Documentation - Add a new CLI Concepts document as another way of framing clap - Expand the `typed_derive` cookbook entry ### [`v4.5.47`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4547---2025-09-02) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.46...v4.5.47) ##### Features - Added `impl FromArgMatches for ()` - Added `impl Args for ()` - Added `impl Subcommand for ()` - Added `impl FromArgMatches for Infallible` - Added `impl Subcommand for Infallible` ##### Fixes - *(derive)* Update runtime error text to match `clap` ### [`v4.5.46`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4546---2025-08-26) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.45...v4.5.46) ##### Features - Expose `StyledStr::push_str` ### [`v4.5.45`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4545---2025-08-12) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.44...v4.5.45) ##### Fixes - *(unstable-v5)* `ValueEnum` variants now use the full doc comment, not summary, for `PossibleValue::help` ### [`v4.5.44`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4544---2025-08-11) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.43...v4.5.44) ##### Features - Add `Command::mut_subcommands` ### [`v4.5.43`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4543---2025-08-06) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.42...v4.5.43) ##### Fixes - *(help)* In long help, list Possible Values before defaults, rather than after, for a more consistent look ### [`v4.5.42`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4542---2025-07-30) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.41...v4.5.42) ##### Fixes - Include subcommand visible long aliases in `--help` ### [`v4.5.41`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4541---2025-07-09) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.40...v4.5.41) ##### Features - Add `Styles::context` and `Styles::context_value` to customize the styling of `[default: value]` like notes in the `--help` ### [`v4.5.40`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4540---2025-06-09) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.39...v4.5.40) ##### Features - Support quoted ids in `arg!()` macro (e.g. `arg!("check-config": ...)`) ### [`v4.5.39`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4539---2025-05-27) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.38...v4.5.39) ##### Fixes - *(help)* Show short flag aliases before long - *(help)* Merge the short and long flag alias lists ### [`v4.5.38`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4538---2025-05-11) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.37...v4.5.38) ##### Fixes - *(help)* When showing aliases, include leading `--` or `-` ### [`v4.5.37`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4537---2025-04-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.36...v4.5.37) ##### Features - Added `ArgMatches::try_clear_id()` ### [`v4.5.36`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4536---2025-04-11) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.35...v4.5.36) ##### Fixes - *(help)* Revert 4.5.35's "Don't leave space for shorts if there are none" for now ### [`v4.5.35`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4535---2025-04-01) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.34...v4.5.35) ##### Fixes - *(help)* Align positionals and flags when put in the same `help_heading` - *(help)* Don't leave space for shorts if there are none ### [`v4.5.34`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4534---2025-03-27) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.33...v4.5.34) ##### Fixes - *(help)* Don't add extra blank lines with `flatten_help(true)` and subcommands without arguments ### [`v4.5.33`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4533---2025-03-26) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.32...v4.5.33) ##### Fixes - *(error)* When showing the usage of a suggestion for an unknown argument, don't show the group ### [`v4.5.32`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4532---2025-03-10) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.31...v4.5.32) ##### Features - Add `Error::remove` ##### Documentation - *(cookbook)* Switch from `humantime` to `jiff` - *(tutorial)* Better cover required vs optional ##### Internal - Update `pulldown-cmark` ### [`v4.5.31`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4531---2025-02-24) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.30...v4.5.31) ##### Features - Add `ValueParserFactory` for `Saturating<T>` ### [`v4.5.30`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4530---2025-02-17) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.29...v4.5.30) ##### Fixes - *(assert)* Allow `num_args(0..=1)` to be used with `SetTrue` - *(assert)* Clean up rendering of `takes_values` assertions ### [`v4.5.29`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4529---2025-02-11) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.28...v4.5.29) ##### Fixes - Change `ArgMatches::args_present` so not-present flags are considered not-present (matching the documentation) ### [`v4.5.28`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4528---2025-02-03) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.27...v4.5.28) ##### Features - *(derive)* Unstable support for full markdown syntax for doc comments, enabled with `unstable-markdown` ### [`v4.5.27`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4527---2025-01-20) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.26...v4.5.27) ##### Documentation - Iterate on tutorials and reference based on feedback ### [`v4.5.26`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4526---2025-01-09) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.25...v4.5.26) ##### Fixes - *(error)* Reduce binary size with the `suggestions` feature ### [`v4.5.25`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4525---2025-01-09) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.24...v4.5.25) ##### Fixes - *(help)* Reduce binary size ### [`v4.5.24`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4524---2025-01-07) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.23...v4.5.24) ##### Fixes - *(parser)* Correctly handle defaults with `ignore_errors(true)` and when a suggestion is provided for an unknown argument ### [`v4.5.23`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4523---2024-12-05) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.22...v4.5.23) ##### Fixes - *(parser)* When check `allow_negative_numbers`, allow `E` again ### [`v4.5.22`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4522---2024-12-03) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.21...v4.5.22) ##### Fixes - *(assert)* Catch bugs with arguments requiring themself ### [`v4.5.21`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4521---2024-11-13) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.20...v4.5.21) ##### Fixes - *(parser)* Ensure defaults are filled in on error with `ignore_errors(true)` ### [`v4.5.20`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4520---2024-10-08) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.19...v4.5.20) ##### Features - *(unstable)* Add `CommandExt` ### [`v4.5.19`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4519---2024-10-01) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.18...v4.5.19) ##### Internal - Update dependencies ### [`v4.5.18`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4518---2024-09-20) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.17...v4.5.18) ##### Features - *(builder)* Expose `Arg::get_display_order` and `Command::get_display_order` ### [`v4.5.17`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4517---2024-09-04) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.16...v4.5.17) ##### Fixes - *(help)* Style required argument groups - *(derive)* Improve error messages when unsupported fields are used ### [`v4.5.16`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4516---2024-08-15) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.15...v4.5.16) ##### Fixes - *(derive)* Improve error messages when `derive` feature is missing ### [`v4.5.15`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4515---2024-08-10) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.14...v4.5.15) ##### Compatiblity - *(unstable-ext)* `Arg::remove` changed return types ##### Fixes - *(unstable-ext)* Make `Arg::remove` return the removed item ### [`v4.5.14`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4514---2024-08-08) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.13...v4.5.14) ##### Features - *(unstable-ext)* Added `Arg::add` for attaching arbitrary state, like completion hints, to `Arg` without `Arg` knowing about it ### [`v4.5.13`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4513---2024-07-31) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.12...v4.5.13) ##### Fixes - *(derive)* Improve error message when `#[flatten]`ing an optional `#[group(skip)]` - *(help)* Properly wrap long subcommand descriptions in help ### [`v4.5.12`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4512---2024-07-31) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.11...v4.5.12) ### [`v4.5.11`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4511---2024-07-25) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.10...v4.5.11) ### [`v4.5.10`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4510---2024-07-23) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.9...v4.5.10) ### [`v4.5.9`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#459---2024-07-09) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.8...v4.5.9) ##### Fixes - *(error)* When defining a custom help flag, be sure to suggest it like we do the built-in one ### [`v4.5.8`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#458---2024-06-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.7...v4.5.8) ##### Fixes - Reduce extra flushes ### [`v4.5.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#457---2024-06-10) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.6...v4.5.7) ##### Fixes - Clean up error message when too few arguments for `num_args` ### [`v4.5.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#456---2024-06-06) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.5...v4.5.6) ### [`v4.5.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4551---2025-10-29) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.4...v4.5.5) ##### Fixes - *(help)* Correctly calculate padding for short flags that take a value - *(help)* Don't panic on short flags using `ArgAction::Count` ### [`v4.5.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4549---2025-10-13) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.3...v4.5.4) ##### Fixes - *(help)* Correctly wrap when ANSI escape codes are present ### [`v4.5.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4539---2025-05-27) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.2...v4.5.3) ##### Fixes - *(help)* Show short flag aliases before long - *(help)* Merge the short and long flag alias lists ### [`v4.5.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4529---2025-02-11) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.1...v4.5.2) ##### Fixes - Change `ArgMatches::args_present` so not-present flags are considered not-present (matching the documentation) ### [`v4.5.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4519---2024-10-01) [Compare Source](https://github.com/clap-rs/clap/compare/v4.5.0...v4.5.1) ##### Internal - Update dependencies ### [`v4.5.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#450---2024-02-08) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.18...v4.5.0) ##### Compatibility - Update MSRV to 1.74 ### [`v4.4.18`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4418---2024-01-16) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.17...v4.4.18) ##### Fixes - *(error)* When lacking `usage` feature, ensure the list of required arguments is unique ### [`v4.4.17`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4417---2024-01-15) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.16...v4.4.17) ##### Fixes - Fix `panic!` when mixing `args_conflicts_with_subcommands` with `ArgGroup` (which is implicit with `derive`) introduced in 4.4.15 ### [`v4.4.16`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4416---2024-01-12) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.15...v4.4.16) ##### Fixes - Ensure invalid escape sequences in user-defined strings are correctly stripped when terminal doesn't support color ### [`v4.4.15`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4415---2024-01-11) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.14...v4.4.15) ##### Fixes - Improve error for `args_conflicts_with_subcommands` - Ensure we error for `args_conflicts_with_subcommands` when using subcommand short and long flags ### [`v4.4.14`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4414---2024-01-08) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.13...v4.4.14) ##### 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 ### [`v4.4.13`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4413---2024-01-04) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.12...v4.4.13) ##### Documentation - Fix link to structopt migration guide ### [`v4.4.12`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4412---2023-12-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.11...v4.4.12) ##### Performance - Only ask `TypedValueParser` for possible values if needed ### [`v4.4.11`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4411---2023-12-04) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.10...v4.4.11) ##### Features - Add `Command::mut_group` ### [`v4.4.10`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4410---2023-11-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.9...v4.4.10) ##### Documentation - Link out to changelog - Cross link derive's attribute reference to derive tutorial ### [`v4.4.9`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#449---2023-11-27) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.8...v4.4.9) ##### Fixes - *(help)* Show correct `Command::about` under flattened headings - *(help)* Respect `hide` when flattening subcommands ### [`v4.4.8`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#448---2023-11-10) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.7...v4.4.8) ##### Features - Add `Command::flatten_help` to allow `git stash -h` like help for subcommands ### [`v4.4.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#447---2023-10-24) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.6...v4.4.7) ##### Performance - Reduced code size ### [`v4.4.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#446---2023-09-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.5...v4.4.6) ##### Internal - Upgrade `anstream` ### [`v4.4.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#445---2023-09-25) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.4...v4.4.5) ##### 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 ### [`v4.4.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#444---2023-09-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.3...v4.4.4) ##### Internal - Update `terminal_size` to 0.3 ### [`v4.4.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#443---2023-09-12) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.2...v4.4.3) ##### Documentation - *(derive)* Clarify use of attributes within the tutorial - Split sections in the builder and derive tutorials into separate modules ### [`v4.4.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#442---2023-08-31) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.1...v4.4.2) ##### Performance - Improve build times by removing `once_cell` dependency ### [`v4.4.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4418---2024-01-16) [Compare Source](https://github.com/clap-rs/clap/compare/v4.4.0...v4.4.1) ##### Fixes - *(error)* When lacking `usage` feature, ensure the list of required arguments is unique ### [`v4.4.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#440---2023-08-24) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.24...v4.4.0) ##### compatibility - update msrv to 1.70.0 ### [`v4.3.24`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4324---2023-08-23) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.23...v4.3.24) ##### Fixes - Ensure column padding is preserved in `--help` with custom templates ### [`v4.3.23`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4323---2023-08-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.22...v4.3.23) ##### Fixes - Fixed `UnknownArgumentValueParser` to not error on flag's absence ### [`v4.3.22`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4322---2023-08-17) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.21...v4.3.22) ##### Features - Add `UnknownArgumentValueParser` for injecting errors for improving the experience with errors ### [`v4.3.21`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4321---2023-08-08) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.20...v4.3.21) ##### Features - Expose `TryMapValueParser` so the type can be named ### [`v4.3.20`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4320---2023-08-08) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.19...v4.3.20) ##### Features - `Command::mut_args` for modifying all arguments en masse ### [`v4.3.19`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4319---2023-07-21) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.18...v4.3.19) ##### Fixes - *(parse)* Respect `value_terminator` even in the presence of later multiple-value positional arguments ### [`v4.3.18`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4318---2023-07-21) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.17...v4.3.18) ##### Fixes - *(parse)* Suggest `--` in fewer places where it won't work ### [`v4.3.17`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4317---2023-07-19) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.16...v4.3.17) ##### Fixes - *(help)* Address a regression in wrapping `PossibleValue` descriptions in `--help` ### [`v4.3.16`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4316---2023-07-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.15...v4.3.16) ##### Fixes - Don't assert when stateful value parsers fail on defaults (e.g. checking if a path exists) ### [`v4.3.15`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4315---2023-07-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.14...v4.3.15) ##### Features - *(unstable-styles)* Re-export `anstyle` ##### Documentation - *(unstable-styles)* Provide more examples ### [`v4.3.14`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4314---2023-07-17) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.13...v4.3.14) ##### 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 ### [`v4.3.13`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4313---2023-07-17) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.12...v4.3.13) ### [`v4.3.12`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4312---2023-07-14) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.11...v4.3.12) ##### Fixes - *(derive)* Don't error on enum variant field attributes ### [`v4.3.11`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4311---2023-07-05) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.10...v4.3.11) ##### Features - *(derive)* Support fields wrapped in `num::Wrapping`, `Box`, or `Arc` - *(derive)* Support `Box<str>`, `Box<OsStr>`, and `Box<Path>` ### [`v4.3.10`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4310---2023-06-30) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.9...v4.3.10) ##### Performance - Drop a dependency, reducing binary size by 1.3 KiB ### [`v4.3.9`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#439---2023-06-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.8...v4.3.9) ##### Fixes - `Command::ignore_errors` no longer masks help/version ### [`v4.3.8`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#438---2023-06-23) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.7...v4.3.8) ##### Fixes - Error on ambiguity with `infer_long_arg`, rather than arbitrarily picking one, matching the documentation and subcommand's behavior ### [`v4.3.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#437---2023-06-23) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.6...v4.3.7) ##### Documentation - Further clarify magic behavior in derive tutorial - Further clarify derive API's relationship to builder within the tutorial ### [`v4.3.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#436---2023-06-23) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.5...v4.3.6) ##### Documentation - Suggest `clio` ### [`v4.3.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#435---2023-06-20) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.4...v4.3.5) - `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 ### [`v4.3.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#434---2023-06-14) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.3...v4.3.4) ##### Features - Add `Error::exit_code` ### [`v4.3.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#433---2023-06-09) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.2...v4.3.3) ##### Features - `Command::defer` for delayed initialization of subcommands to reduce startup times of large applications like deno ### [`v4.3.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4324---2023-08-23) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.1...v4.3.2) ##### Fixes - Ensure column padding is preserved in `--help` with custom templates ### [`v4.3.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4319---2023-07-21) [Compare Source](https://github.com/clap-rs/clap/compare/v4.3.0...v4.3.1) ##### Fixes - *(parse)* Respect `value_terminator` even in the presence of later multiple-value positional arguments ### [`v4.3.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#430---2023-05-19) [Compare Source](https://github.com/clap-rs/clap/compare/v4.2.7...v4.3.0) ##### 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 ### [`v4.2.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#427---2023-05-02) [Compare Source](https://github.com/clap-rs/clap/compare/v4.2.6...v4.2.7) ##### Fixes - Correctly track remaining length for iterators provided by `ArgMatches` ### [`v4.2.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#426---2023-05-02) [Compare Source](https://github.com/clap-rs/clap/compare/v4.2.5...v4.2.6) ##### Features - `impl Eq<std::any::TypeId> for clap_builder::util::AnyValueId` ### [`v4.2.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#425---2023-04-27) [Compare Source](https://github.com/clap-rs/clap/compare/v4.2.4...v4.2.5) ##### Fixes - Improve panic when a group requires a non-existent ID ### [`v4.2.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#424---2023-04-19) [Compare Source](https://github.com/clap-rs/clap/compare/v4.2.3...v4.2.4) ##### Documentation - Corrected docs for `Command::style` ### [`v4.2.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#423---2023-04-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.2.2...v4.2.3) ##### Features - `Command::styles` for theming help/errors (behind `unstable-styles`) ### [`v4.2.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#422---2023-04-13) [Compare Source](https://github.com/clap-rs/clap/compare/v4.2.1...v4.2.2) ##### Internal - Update dependencies ### [`v4.2.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#421---2023-03-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.2.0...v4.2.1) ##### Fixes - Don't highlight uninteresting parts of the error message ### [`v4.2.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#420---2023-03-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.14...v4.2.0) ##### Compatibility - Removed the languishing `unstable-replace` feature (open to discussion at [#&#8203;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 [#&#8203;4638](https://github.com/clap-rs/clap/issues/4638)) ### [`v4.1.14`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4114---2023-03-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.13...v4.1.14) ##### 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 ### [`v4.1.13`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4113---2023-03-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.12...v4.1.13) ##### Performance - Reduce repeated alloc calls when building a `Command` - Reduce duplicate dependencies for faster builds ### [`v4.1.12`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4112---2023-03-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.11...v4.1.12) ##### Internal - *(derive)* Update to `syn` v2 ##### Performance - *(derive)* Faster build times by dropping `proc-macro-error` dependency ### [`v4.1.11`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4111---2023-03-17) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.10...v4.1.11) ##### Internal - Update `bitflags` ### [`v4.1.10`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4110---2023-03-17) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.9...v4.1.10) ##### Fixes - *(help)* On Windows, avoid underlined text artifacts ### [`v4.1.9`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#419---2023-03-16) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.8...v4.1.9) ##### Fixes - *(assert)* Improve the assert when using the wrong action with `get_count` / `get_flag` ### [`v4.1.8`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#418---2023-02-27) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.7...v4.1.8) ##### Fixes - *(derive)* Don't `deny` lints on the users behalf ### [`v4.1.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#417---2023-02-27) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.6...v4.1.7) ##### Fixes - *(derive)* Hide some nightly clippy warnings ### [`v4.1.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#416---2023-02-15) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.5...v4.1.6) ##### Fixes - *(help)* Don't show long help for `--help` just because hidden possible values include a description ### [`v4.1.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#415---2023-02-15) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.4...v4.1.5) ##### Fixes - *(help)* Don't show long help for `--help` just because a hidden arg has a possible value with a description ### [`v4.1.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#414---2023-01-24) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.3...v4.1.4) ##### Fixes - *(help)* Respect `disable_colored_help` when using `arg_required_else_help` ##### Performance - Speed up compiling `arg!` macro ### [`v4.1.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#413---2023-01-23) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.2...v4.1.3) ##### 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` ### [`v4.1.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#412---2023-01-23) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.1...v4.1.2) ##### Fixes - In documentation, refer to `get_flag`, rather than `get_one::<bool>` ### [`v4.1.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4114---2023-03-28) [Compare Source](https://github.com/clap-rs/clap/compare/v4.1.0...v4.1.1) ##### 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 ### [`v4.1.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#410---2023-01-13) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.32...v4.1.0) ##### 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) ### [`v4.0.32`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4032---2022-12-22) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.31...v4.0.32) ##### Fixes - *(parser)* When overriding `required(true)`, consider args that conflict with its group ### [`v4.0.31`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4031---2022-12-22) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.30...v4.0.31) ##### Performance - Speed up parsing when a lot of different flags are present (100 unique flags) ### [`v4.0.30`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4030---2022-12-21) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.29...v4.0.30) ##### Fixes - *(error)* Improve error for `args_conflicts_with_subcommand` ### [`v4.0.29`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4029---2022-11-29) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.28...v4.0.29) ### [`v4.0.28`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4028---2022-11-29) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.27...v4.0.28) ##### Fixes - Fix wasm support which was broken in 4.0.27 ### [`v4.0.27`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4027---2022-11-24) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.26...v4.0.27) ##### Features - Have `Arg::value_parser` accept `Vec<impl Into<PossibleValue>>` - Implement `Display` and `FromStr` for `ColorChoice` ##### Fixes - Remove soundness issue by switching from `atty` to `is-terminal` ### [`v4.0.26`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4026---2022-11-16) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.25...v4.0.26) ##### Fixes - *(error)* Fix typos in `ContextKind::as_str` ### [`v4.0.25`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4025---2022-11-15) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.24...v4.0.25) ##### Features - *(error)* Report available subcommands when required subcommand is missing ### [`v4.0.24`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4024---2022-11-14) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.23...v4.0.24) ##### Fixes - Avoid panic when printing an argument that isn't built ### [`v4.0.23`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4023---2022-11-11) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.22...v4.0.23) ##### Fixes - Don't panic on reporting invalid-long errors when followed by invalid UTF8 - *(help)* Clarified argument to `help` subcommand ### [`v4.0.22`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4022---2022-11-07) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.21...v4.0.22) ##### Fixes - *(help)* Don't overflow into next-line-help early due to stale (pre-v4) padding calculations ### [`v4.0.21`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4021---2022-11-07) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.20...v4.0.21) ##### 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) ### [`v4.0.20`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4020---2022-11-07) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.19...v4.0.20) ##### Fixes - *(derive)* Allow defaulted value parser for '()' fields ### [`v4.0.19`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4019---2022-11-04) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.18...v4.0.19) ##### Features - `ColorChoice` now implements `ValueEnum` ### [`v4.0.18`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4018---2022-10-20) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.17...v4.0.18) ##### Fixes - *(derive)* Allow `#[command(skip)]` to also work with enum variants with a value ### [`v4.0.17`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4017---2022-10-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.16...v4.0.17) ##### Fixes - Allow using `Arg::last(true)` with `Arg::value_hint(ValueHint::CommandWithArguments)` ### [`v4.0.16`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4016---2022-10-18) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.15...v4.0.16) ##### Fixes - `Arg::exclusive(true)` should not be exclusive with the argument's own `ArgGroup` ### [`v4.0.15`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4015---2022-10-13) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.14...v4.0.15) ##### Fixes - *(error)* Don't suggest `--` when it doesn't help - *(error)* Be more consistent in quoting, punctuation, and indentation in errors ### [`v4.0.14`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4014---2022-10-12) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.13...v4.0.14) ##### Fixes - Only put `ArgGroup` in `ArgMatches` when explicitly specified, fixing derives handling of option-flattened fields ([#&#8203;4375](https://github.com/clap-rs/clap/issues/4375)) ### [`v4.0.13`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4013---2022-10-11) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.12...v4.0.13) ##### Features - *(derive)* Allow `()` for fields to mean "don't read" ([#&#8203;4371](https://github.com/clap-rs/clap/issues/4371)) ### [`v4.0.12`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4012---2022-10-10) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.11...v4.0.12) ##### 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` ### [`v4.0.11`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4011---2022-10-09) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.10...v4.0.11) ##### Fixes - *(help)* Fix wrapping calculations with ANSI escape codes ### [`v4.0.10`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4010---2022-10-05) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.9...v4.0.10) ##### Features - *(derive)* Support `#[arg(flatten)]` on `Option` types ([#&#8203;4211](https://github.com/clap-rs/clap/issues/4211), [#&#8203;4350](https://github.com/clap-rs/clap/issues/4350)) ### [`v4.0.9`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#409---2022-10-03) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.8...v4.0.9) ##### Fixes - *(derive)* Process doc comments for `#[command(subcommand)]` like in clap v3 ### [`v4.0.8`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#408---2022-10-01) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.7...v4.0.8) ##### Fixes - *(derive)* Remove a low-value assert preventing defaulting `Help` and `Version` actions ### [`v4.0.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#407---2022-09-30) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.6...v4.0.7) ##### Features - *(derive)* Populate implicit ArgGroup ([#&#8203;3165](https://github.com/clap-rs/clap/issues/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 ### [`v4.0.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#406---2022-09-30) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.5...v4.0.6) ##### Features - *(derive)* Support `#[group(skip)]` ([#&#8203;4279](https://github.com/clap-rs/clap/issues/4279), [#&#8203;4301](https://github.com/clap-rs/clap/issues/4301)) ### [`v4.0.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#405---2022-09-30) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.4...v4.0.5) ### [`v4.0.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#404---2022-09-29) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.3...v4.0.4) ##### Fixes - *(error)* Specialize the self-conflict error to look like clap v3 ### [`v4.0.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4032---2022-12-22) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.2...v4.0.3) ##### Fixes - *(parser)* When overriding `required(true)`, consider args that conflict with its group ### [`v4.0.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4029---2022-11-29) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.1...v4.0.2) ### [`v4.0.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#4019---2022-11-04) [Compare Source](https://github.com/clap-rs/clap/compare/v4.0.0...v4.0.1) ##### Features - `ColorChoice` now implements `ValueEnum` ### [`v4.0.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#400---2022-09-28) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.25...v4.0.0) ##### 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 <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 ``` - 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<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: - 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 <option> ``` After: ```rust .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. ##### Breaking Changes Subtle changes (i.e. compiler won't catch): - `arg!` now sets one of ([#&#8203;3795](https://github.com/clap-rs/clap/issues/3795)): - `ArgAction::SetTrue`, requiring `ArgMatches::get_flag` instead of `ArgMatches::is_present` - `ArgAction::Count`, requiring `ArgMatches::get_count` instead of `ArgMatches::occurrences_of` - `ArgAction::Set`, requiring `ArgMatches::get_one` instead of `ArgMatches::value_of` - `ArgAction::Append`, requiring `ArgMatches::get_many` instead of `ArgMatches::values_of` - `ArgAction::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 ([#&#8203;4261](https://github.com/clap-rs/clap/issues/4261)) - By default, an `Arg`s default action is `ArgAction::Set`, rather than `ArgAction::IncOccurrence` to reduce confusing magic through consistency ([#&#8203;2687](https://github.com/clap-rs/clap/issues/2687), [#&#8203;4032](https://github.com/clap-rs/clap/issues/4032), see also [#&#8203;3977](https://github.com/clap-rs/clap/issues/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 ([#&#8203;4056](https://github.com/clap-rs/clap/issues/4056)) - Removed lifetimes from `Command`, `Arg`, `ArgGroup`, and `PossibleValue`, assuming `'static`. `string` feature flag will enable support for `String`s ([#&#8203;1041](https://github.com/clap-rs/clap/issues/1041), [#&#8203;2150](https://github.com/clap-rs/clap/issues/2150), [#&#8203;4223](https://github.com/clap-rs/clap/issues/4223)) - `arg!(--flag <value>)` is now optional, instead of required. Add `.required(true)` at the end to restore the original behavior ([#&#8203;4206](https://github.com/clap-rs/clap/issues/4206)) - Added default feature flags, `help`, `usage` and `error-context`, requiring adding them back in if `default-features = false` ([#&#8203;4236](https://github.com/clap-rs/clap/issues/4236)) - *(parser)* Always fill in `""` argument for external subcommands to make it easier to distinguish them from built-in commands ([#&#8203;3263](https://github.com/clap-rs/clap/issues/3263)) - *(parser)* Short flags now have higher precedence than hyphen values with `Arg::allow_hyphen_values`, to be consistent with `Command::allow_hyphen_values` ([#&#8203;4187](https://github.com/clap-rs/clap/issues/4187)) - *(parser)* `Arg::value_terminator` must be its own argument on the CLI rather than being in a delimited list ([#&#8203;4025](https://github.com/clap-rs/clap/issues/4025)) - *(help)* Line wrapping of help is now behind the existing `wrap_help` feature flag, either enable it or hard code your wraps ([#&#8203;4258](https://github.com/clap-rs/clap/issues/4258)) - *(help)* Make `DeriveDisplayOrder` the default and removed the setting. To sort help, set `next_display_order(None)` ([#&#8203;2808](https://github.com/clap-rs/clap/issues/2808)) - *(help)* Subcommand display order respects `Command::next_display_order` instead of `DeriveDisplayOrder` and using its own initial display order value ([#&#8203;2808](https://github.com/clap-rs/clap/issues/2808)) - *(help)* Subcommands are now listed before arguments. To get the old behavior, see `Command::help_template` ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132)) - *(help)* Help headings are now title cased, making any user-provided help headings inconsistent. To get the old behavior, see `Command::help_template`, `Arg::help_heading`, and `Command::subcommand_help_heading` ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132)) - *(help)* "Command" is used as the section heading for subcommands and `COMMAND` for the value name. To get the old behavior, see `Command::subcommand_help_heading` and `Arg::subcommand_value_name` ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4155](https://github.com/clap-rs/clap/issues/4155)) - *(help)* Whitespace in help output is now trimmed to ensure consistency regardless of how well a template matches the users needs. ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4156](https://github.com/clap-rs/clap/issues/4156)) - *(help)* name/version/author are removed by default from help output. To get the old behavior, see `Command::help_template`. ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4160](https://github.com/clap-rs/clap/issues/4160)) - *(help)* Indentation for second-line usage changed. ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4188](https://github.com/clap-rs/clap/issues/4188)) - *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag ([#&#8203;3776](https://github.com/clap-rs/clap/issues/3776)) - *(derive)* Leave `Arg::id` as `verbatim` casing, requiring updating of string references to other args like in `conflicts_with` or `requires` ([#&#8203;3282](https://github.com/clap-rs/clap/issues/3282)) - *(derive)* Doc comments for `ValueEnum` variants will now show up in `--help` ([#&#8203;3312](https://github.com/clap-rs/clap/issues/3312)) - *(derive)* When deriving `Args`, and `ArgGroup` is created using the type's name, reserving it for future use ([#&#8203;2621](https://github.com/clap-rs/clap/issues/2621), [#&#8203;4209](https://github.com/clap-rs/clap/issues/4209)) - *(derive)* `next_help_heading` can now leak out of a `#[clap(flatten)]`, like all other command settings ([#&#8203;4222](https://github.com/clap-rs/clap/issues/4222)) Easier to catch changes: - Looking up a group in `ArgMatches` now returns the arg `Id`s, rather than the values to reduce overhead and offer more flexibility. ([#&#8203;4072](https://github.com/clap-rs/clap/issues/4072)) - Changed `Arg::number_of_values` (average-across-occurrences) to `Arg::num_args` (per-occurrence) (raw CLI args, not parsed values) ([#&#8203;2688](https://github.com/clap-rs/clap/issues/2688), [#&#8203;4023](https://github.com/clap-rs/clap/issues/4023)) - `num_args(0)` no longer implies `takes_value(true).multiple_values(true)` ([#&#8203;4023](https://github.com/clap-rs/clap/issues/4023)) - `num_args(1)` no longer implies `multiple_values(true)` ([#&#8203;4023](https://github.com/clap-rs/clap/issues/4023)) - Does not check default or env values, only what the user explicitly passes in ([#&#8203;4025](https://github.com/clap-rs/clap/issues/4025)) - No longer terminates on delimited values ([#&#8203;4025](https://github.com/clap-rs/clap/issues/4025)) - Replace `Arg::min_values` (across all occurrences) with `Arg::num_args(N..)` (per occurrence) to reduce confusion over different value count APIs ([#&#8203;4023](https://github.com/clap-rs/clap/issues/4023)) - Replace `Arg::max_values` (across all occurrences) with `Arg::num_args(1..=M)` (per occurrence) to reduce confusion over different value count APIs ([#&#8203;4023](https://github.com/clap-rs/clap/issues/4023)) - Replace `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 ([#&#8203;4023](https://github.com/clap-rs/clap/issues/4023)) - Replace `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 APIs - Remove `Arg::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 ([#&#8203;4026](https://github.com/clap-rs/clap/issues/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)`. ([#&#8203;4056](https://github.com/clap-rs/clap/issues/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)`. ([#&#8203;4056](https://github.com/clap-rs/clap/issues/4056)) - `ArgAction::SetTrue` and `ArgAction::SetFalse` now prioritize `Arg::default_missing_value` over their standard behavior ([#&#8203;4000](https://github.com/clap-rs/clap/issues/4000)) - Changed `Arg::requires_ifs` and `Arg::default_value*_ifs*` to taking an `ArgPredicate`, removing ambiguity with `None` when accepting owned and borrowed types ([#&#8203;4084](https://github.com/clap-rs/clap/issues/4084)) - Removed `PartialEq` and `Eq` from `Command` so we could change external subcommands to use a `ValueParser` ([#&#8203;3990](https://github.com/clap-rs/clap/issues/3990)) - Various `Arg`, `Command`, and `ArgGroup` calls were switched from accepting `&[]` to `[]` via `IntoIterator` to be more flexible ([#&#8203;4072](https://github.com/clap-rs/clap/issues/4072)) - `Arg::short_aliases` and other builder functions that took `&[]` need the `&` dropped ([#&#8203;4081](https://github.com/clap-rs/clap/issues/4081)) - `ErrorKind` and `Result` moved into the `error` module - `ErrorKind::EmptyValue` replaced with `ErrorKind::InvalidValue` to remove an unnecessary special case ([#&#8203;3676](https://github.com/clap-rs/clap/issues/3676), [#&#8203;3968](https://github.com/clap-rs/clap/issues/3968)) - `ErrorKind::UnrecognizedSubcommand` replaced with `ErrorKind::InvalidSubcommand` to remove an unnecessary special case ([#&#8203;3676](https://github.com/clap-rs/clap/issues/3676)) - Changed the default type of `allow_external_subcommands` from `String` to `OsString` as that is less likely to cause bugs in user applications ([#&#8203;3990](https://github.com/clap-rs/clap/issues/3990)) - *(help)* `Command::render_usage` now returns a `StyledStr` ([#&#8203;4248](https://github.com/clap-rs/clap/issues/4248)) - *(derive)* Changed the default for arguments from `parse` to `value_parser`, removing `parse` support ([#&#8203;3827](https://github.com/clap-rs/clap/issues/3827), [#&#8203;3981](https://github.com/clap-rs/clap/issues/3981)) - `#[clap(value_parser)]` and `#[clap(action)]` are now redundant - *(derive)* `subcommand_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 ([#&#8203;3280](https://github.com/clap-rs/clap/issues/3280)) - *(derive)* Remove `arg_enum` attribute in favor of `value_enum` to match the new name (we didn't have support in v3 to mark it deprecated) ([#&#8203;4127](https://github.com/clap-rs/clap/issues/4127)) - *(parser)* Assert when the CLI looksup an unknown args when external subcommand support is enabled to help catch bugs ([#&#8203;3703](https://github.com/clap-rs/clap/issues/3703)) - *(assert)* Sometimes `Arg::default_missing_value` didn't require `num_args(0..=N)`, now it does ([#&#8203;4023](https://github.com/clap-rs/clap/issues/4023)) - *(assert)* Leading dashes in `Arg::long` are no longer allowed ([#&#8203;3691](https://github.com/clap-rs/clap/issues/3691)) - *(assert)* Disallow more `value_names` than `num_args` ([#&#8203;2695](https://github.com/clap-rs/clap/issues/2695)) - *(assert)* Always enforce that version is specified when the `ArgAction::Version` is used - *(assert)* Add missing `#[track_caller]`s to make it easier to debug asserts - *(assert)* Ensure `overrides_with` IDs are valid - *(assert)* Ensure no self-`overrides_with` now that Actions replace it - *(assert)* Ensure subcommand names are not duplicated - *(assert)* Assert on `mut_arg` receiving an invalid arg ID or `mut_subcommand` receiving an invalid command name ##### Compatibility MSRV 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 thing - `Arg::requires_all` in favor of `Arg::requires_ifs` now that it takes an `ArgPredicate` to avoid having multiple ways of doing the same thing - `Arg::number_of_values` in favor of `Arg::num_args` to clarify semantic differences - `default_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` ([#&#8203;4141](https://github.com/clap-rs/clap/issues/4141)) - `Arg::env_os` in favor of `Arg::env` - `Command::dont_collapse_args_in_usage` is now the default ([#&#8203;4151](https://github.com/clap-rs/clap/issues/4151)) - `Command::trailing_var_arg` in favor of `Arg::trailing_var_arg` to make it clearer which arg it is meant to apply to ([#&#8203;4187](https://github.com/clap-rs/clap/issues/4187)) - `Command::allow_hyphen_values` in favor of `Arg::allow_hyphen_values` to make it clearer which arg it is meant to apply to ([#&#8203;4187](https://github.com/clap-rs/clap/issues/4187)) - `Command::allow_negative_numbers` in favor of `Arg::allow_negative_numbers` to make it clearer which arg it is meant to apply to ([#&#8203;4187](https://github.com/clap-rs/clap/issues/4187)) - *(help)* Deprecated `Command::write_help` and `Command::write_long_help` in favor of `Command::render_help` and `Command::render_long_help` ([#&#8203;4248](https://github.com/clap-rs/clap/issues/4248)) - *(derive)* `structopt` and `clap` attributes in favor of the more specific `command`, `arg`, and `value` to open the door for [more features](https://github.com/clap-rs/clap/issues/1807) and [clarify relationship to the builder](https://github.com/clap-rs/clap/discussions/4090) ([#&#8203;1807](https://github.com/clap-rs/clap/issues/1807), [#&#8203;4180](https://github.com/clap-rs/clap/issues/4180)) - *(derive)* `#[clap(value_parser)]` and `#[clap(action)]` defaulted attributes (its the default) ([#&#8203;3976](https://github.com/clap-rs/clap/issues/3976)) Behavior Changes - *(help)* With `wrap_help` feature, if the terminal size cannot be determined, `LINES` and `COLUMNS` variables are used ([#&#8203;4186](https://github.com/clap-rs/clap/issues/4186)) ##### Features - `Arg::num_args` now accepts ranges, allowing setting both the minimum and maximum number of values per occurrence ([#&#8203;2688](https://github.com/clap-rs/clap/issues/2688), [#&#8203;4023](https://github.com/clap-rs/clap/issues/4023)) - Allow non-bool `value_parser`s for `ArgAction::SetTrue` / `ArgAction::SetFalse` ([#&#8203;4092](https://github.com/clap-rs/clap/issues/4092)) - Add `From<&OsStr>`, `From<OsString>`, `From<&str>`, and `From<String>` to `value_parser!` ([#&#8203;4257](https://github.com/clap-rs/clap/issues/4257)) - Allow resetting most builder methods - Can now pass runtime generated data to `Command`, `Arg`, `ArgGroup`, `PossibleValue`, etc without managing lifetimes with the `string` feature flag ([#&#8203;2150](https://github.com/clap-rs/clap/issues/2150), [#&#8203;4223](https://github.com/clap-rs/clap/issues/4223)) - New default `error-context`, `help` and `usage` feature flags that can be turned off for smaller binaries ([#&#8203;4236](https://github.com/clap-rs/clap/issues/4236)) - Added `StyledStr::ansi()` to `Display` with ANSI escape codes ([#&#8203;4248](https://github.com/clap-rs/clap/issues/4248)) - *(error)* `Error::apply` for changing the formatter for dropping binary size ([#&#8203;4111](https://github.com/clap-rs/clap/issues/4111)) - *(error)* `Error::render`for formatting the error into a `StyledStr` - *(help)* Show `PossibleValue::help` in long help (`--help`) ([#&#8203;3312](https://github.com/clap-rs/clap/issues/3312)) - *(help)* New `{tab}` variable for `Command::help_template` ([#&#8203;4161](https://github.com/clap-rs/clap/issues/4161)) - *(help)* `Command::render_help` and `Command::render_long_help` for formatting the error into a `StyledStr` ([#&#8203;3873](https://github.com/clap-rs/clap/issues/3873), [#&#8203;4248](https://github.com/clap-rs/clap/issues/4248)) - *(help)* `Command::render_usage` now returns a `StyledStr` ([#&#8203;4248](https://github.com/clap-rs/clap/issues/4248)) ##### Fixes - Verify `required` is not used with conditional required settings ([#&#8203;3660](https://github.com/clap-rs/clap/issues/3660)) - Replaced `cmd.allow_invalid_for_utf8_external_subcommands` with `cmd.external_subcommand_value_parser` ([#&#8203;3733](https://github.com/clap-rs/clap/issues/3733)) - `Arg::default_missing_value` now applies per occurrence rather than if a value is missing across all occurrences ([#&#8203;3998](https://github.com/clap-rs/clap/issues/3998)) - `arg!(--long [value])` to accept `0..=1` per occurrence rather than across all occurrences, making it safe to use with `ArgAction::Append` ([#&#8203;4001](https://github.com/clap-rs/clap/issues/4001)) - Allow `OsStr`s for `Arg::{required_if_eq,required_if_eq_any,required_if_eq_all}` ([#&#8203;4084](https://github.com/clap-rs/clap/issues/4084)) - *(help)* With `wrap_help` feature, if the terminal size cannot be determined, `LINES` and `COLUMNS` variables are used ([#&#8203;4186](https://github.com/clap-rs/clap/issues/4186)) - *(help)* Use `Command::display_name` in the help title rather than `Command::bin_name` - *(help)* Show when a flag is `ArgAction::Count` by adding an `...` ([#&#8203;4003](https://github.com/clap-rs/clap/issues/4003)) - *(help)* Use a more neutral palette for coloring ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4117](https://github.com/clap-rs/clap/issues/4117)) - *(help)* Don't rely on ALL CAPS for help headers ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4123](https://github.com/clap-rs/clap/issues/4123)) - *(help)* List subcommands first, focusing the emphasis on them ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4125](https://github.com/clap-rs/clap/issues/4125)) - *(help)* Do not include global args in `cmd help help` ([#&#8203;4131](https://github.com/clap-rs/clap/issues/4131)) - *(help)* Use `[positional]` in list when relevant ([#&#8203;4144](https://github.com/clap-rs/clap/issues/4144)) - *(help)* Show all `[positional]` in usage ([#&#8203;4151](https://github.com/clap-rs/clap/issues/4151)) - *(help)* Polish up subcommands by referring to them as commands ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4155](https://github.com/clap-rs/clap/issues/4155)) - *(help)* Trim extra whitespace to avoid artifacts from different uses of templates ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4156](https://github.com/clap-rs/clap/issues/4156)) - *(help)* Hint to the user the difference between `-h` / `--help` when applicable ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4159](https://github.com/clap-rs/clap/issues/4159)) - *(help)* Shorten help by eliding name/version/author ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4160](https://github.com/clap-rs/clap/issues/4160)) - *(help)* When short help is long enough to activate `next_line_help`, don't add blank lines ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4190](https://github.com/clap-rs/clap/issues/4190)) - *(help)* Make help output more dense (reducing horizontal whitespace) ([#&#8203;4132](https://github.com/clap-rs/clap/issues/4132), [#&#8203;4192](https://github.com/clap-rs/clap/issues/4192)) - *(help)* Separate subcommand flags with "," like option flags ([#&#8203;4232](https://github.com/clap-rs/clap/issues/4232), [#&#8203;4235](https://github.com/clap-rs/clap/issues/4235)) - *(help)* Quote the suggested help flag ([#&#8203;4220](https://github.com/clap-rs/clap/issues/4220)) - *(version)* Use `Command::display_name` rather than `Command::bin_name` ([#&#8203;3966](https://github.com/clap-rs/clap/issues/3966)) - *(parser)* Always fill in `""` argument for external subcommands ([#&#8203;3263](https://github.com/clap-rs/clap/issues/3263)) - *(parser)* Short flags now have higher precedence than hyphen values with `Arg::allow_hyphen_values`, like `Command::allow_hyphen_values` ([#&#8203;4187](https://github.com/clap-rs/clap/issues/4187)) - *(parser)* Prefer `InvalidSubcommand` over `UnknownArgument` in more cases ([#&#8203;4219](https://github.com/clap-rs/clap/issues/4219)) - *(derive)* Detect escaped external subcommands that look like built-in subcommands ([#&#8203;3703](https://github.com/clap-rs/clap/issues/3703)) - *(derive)* Leave `Arg::id` as `verbatim` casing ([#&#8203;3282](https://github.com/clap-rs/clap/issues/3282)) - *(derive)* Default to `#[clap(value_parser, action)]` instead of `#[clap(parse)]` ([#&#8203;3827](https://github.com/clap-rs/clap/issues/3827)) ### [`v3.2.25`](https://github.com/clap-rs/clap/releases/tag/v3.2.25) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.24...v3.2.25) #### \[3.2.25] - 2023-04-27 ##### Fixes - *(derive)* Resolve warnings in generated code ### [`v3.2.24`](https://github.com/clap-rs/clap/releases/tag/v3.2.24) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.23...v3.2.24) #### \[3.2.24] - 2023-04-25 ##### Fixes - *(derive)* Resolve warnings in generated code ### [`v3.2.23`](https://github.com/clap-rs/clap/releases/tag/v3.2.23) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.22...v3.2.23) #### \[3.2.23] - 2022-10-24 ##### Fixes - Upgrade to `textwrap` 0.16 ### [`v3.2.22`](https://github.com/clap-rs/clap/releases/tag/v3.2.22) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.21...v3.2.22) #### \[3.2.22] - 2022-09-16 ##### Fixes - Unify dependencies on `terminal_size` to the 0.2 release ### [`v3.2.21`](https://github.com/clap-rs/clap/releases/tag/v3.2.21) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.20...v3.2.21) #### \[3.2.21] - 2022-09-12 ##### Features - `TypedValueParser::map` to allow reusing existing value parsers for other purposes ### [`v3.2.20`](https://github.com/clap-rs/clap/releases/tag/v3.2.20) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.19...v3.2.20) #### \[3.2.20] - 2022-09-02 ##### Features - `ArgMatches::get_count` help for `ArgAction::Count` - `ArgMatches::get_flag` help for `ArgAction::SetTrue` / `ArgAction::SetFalse` ### [`v3.2.19`](https://github.com/clap-rs/clap/releases/tag/v3.2.19) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.18...v3.2.19) #### \[3.2.19] - 2022-08-30 ##### Fixes - *(help)* Ensure required arguments for parent commands aren't shown in their subcommands when using `args_conflicts_with_subcommand` ### [`v3.2.18`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3218---2022-08-29) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.17...v3.2.18) ##### Fixes - *(help)* `Command::print_help` now respects `Command::colored_help` - *(derive)* Improved error messages ### [`v3.2.17`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3217---2022-08-12) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.16...v3.2.17) ##### Fixes - *(derive)* Expose `#[clap(id = ...)]` attribute to match Arg's latest API ### [`v3.2.16`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3216---2022-07-30) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.15...v3.2.16) ##### Fixes - Ensure required arguments appear in errors when they are also members of a group ([#&#8203;4004](https://github.com/clap-rs/clap/issues/4004)) ### [`v3.2.15`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3215---2022-07-25) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.14...v3.2.15) ##### Features - *(derive)* New `default_values_t` and `default_values_os_t` attributes ### [`v3.2.14`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3214---2022-07-21) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.13...v3.2.14) ##### Fixes - A `multiple_values` positional followed by another positional now works with multiple flags ### [`v3.2.13`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3213---2022-07-19) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.12...v3.2.13) ##### Documentation - Pulled in tutorials, cookbook, and derive reference into rustdoc ### [`v3.2.12`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3212---2022-07-14) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.11...v3.2.12) ##### Fixes - Allow an arg to declare a conflict with a group ### [`v3.2.11`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3211---2022-07-13) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.10...v3.2.11) ##### Features - Added `Arg::get_all_short_aliaes` and `Arg::get_all_aliases` ### [`v3.2.10`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3210---2022-07-12) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.8...v3.2.10) ##### Fixes - Loosen lifetime on `Command::mut_subcommand` ### [`v3.2.8`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#328---2022-06-30) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.7...v3.2.8) ##### Features - Added `Command::mut_subcommand` to mirror `Command::mut_arg` ### [`v3.2.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#327---2022-06-28) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.6...v3.2.7) ##### Fixes - Global arguments should override env-sourced arguments ### [`v3.2.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#326---2022-06-21) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.5...v3.2.6) ##### Fixes - Don't panic when parsing `--=` ### [`v3.2.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#325---2022-06-15) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.4...v3.2.5) ##### Fixes - *(derive)* Fix regression with `#[clap(default_value_os_t ...)]` introduced in v3.2.3 ### [`v3.2.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#324---2022-06-14) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.3...v3.2.4) ##### Fixes - *(derive)* Provide more clearer deprecation messages for `#[clap(parse)]` attribute ([#&#8203;3832](https://github.com/clap-rs/clap/issues/3832)) ### [`v3.2.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#325---2022-06-15) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.2...v3.2.3) ##### Fixes - *(derive)* Fix regression with `#[clap(default_value_os_t ...)]` introduced in v3.2.3 ### [`v3.2.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#322---2022-06-14) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.1...v3.2.2) ##### Fixes - *(derive)* Improve the highlighted code for deprecation warnings **gated behind `unstable-v4`** - *(derive)* Default to `#[clap(value_parser, action)]` instead of `#[clap(parse)]` ([#&#8203;3827](https://github.com/clap-rs/clap/issues/3827)) ### [`v3.2.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3218---2022-08-29) [Compare Source](https://github.com/clap-rs/clap/compare/v3.2.0...v3.2.1) ##### Fixes - *(help)* `Command::print_help` now respects `Command::colored_help` - *(derive)* Improved error messages ### [`v3.2.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#320---2022-06-13) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.18...v3.2.0) ##### Compatibility MSRV is now 1.56.0 ([#&#8203;3732](https://github.com/clap-rs/clap/issues/3732)) Behavior - Defaults no longer satisfy `required` and its variants ([#&#8203;3793](https://github.com/clap-rs/clap/issues/3793)) - When misusing `ArgMatches::value_of` and friends, debug asserts were turned into panics Moving (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` ([#&#8203;3799](https://github.com/clap-rs/clap/issues/3799)) Replaced - `Arg::allow_invalid_utf8` with `Arg::value_parser(value_parser!(PathBuf))` ([#&#8203;3753](https://github.com/clap-rs/clap/issues/3753)) - `Arg::validator` / `Arg::validator_os` with `Arg::value_parser` ([#&#8203;3753](https://github.com/clap-rs/clap/issues/3753)) - `Arg::validator_regex` with users providing their own `builder::TypedValueParser` ([#&#8203;3756](https://github.com/clap-rs/clap/issues/3756)) - `Arg::forbid_empty_values` with `builder::NonEmptyStringValueParser` / `builder::PathBufValueParser` ([#&#8203;3753](https://github.com/clap-rs/clap/issues/3753)) - `Arg::possible_values` with `Arg::value_parser([...])`, `builder::PossibleValuesParser`, or `builder::EnumValueParser` ([#&#8203;3753](https://github.com/clap-rs/clap/issues/3753)) - `Arg::max_occurrences` with `arg.action(ArgAction::Count).value_parser(value_parser!(u8).range(..N))` for flags ([#&#8203;3797](https://github.com/clap-rs/clap/issues/3797)) - `Arg::multiple_occurrences` with `ArgAction::Append` or `ArgAction::Count` though positionals will need `Arg::multiple_values` ([#&#8203;3772](https://github.com/clap-rs/clap/issues/3772), [#&#8203;3797](https://github.com/clap-rs/clap/issues/3797)) - `Command::args_override_self` with `ArgAction::Set` ([#&#8203;2627](https://github.com/clap-rs/clap/issues/2627), [#&#8203;3797](https://github.com/clap-rs/clap/issues/3797)) - `AppSettings::NoAutoVersion` with `ArgAction` or `Command::disable_version_flag` ([#&#8203;3800](https://github.com/clap-rs/clap/issues/3800)) - `AppSettings::NoHelpVersion` with `ArgAction` or `Command::disable_help_flag` / `Command::disable_help_subcommand` ([#&#8203;3800](https://github.com/clap-rs/clap/issues/3800)) - `ArgMatches::{value_of, value_of_os, value_of_os_lossy, value_of_t}` with `ArgMatches::{get_one,remove_one}` ([#&#8203;3753](https://github.com/clap-rs/clap/issues/3753)) - `ArgMatches::{values_of, values_of_os, values_of_os_lossy, values_of_t}` with `ArgMatches::{get_many,remove_many}` ([#&#8203;3753](https://github.com/clap-rs/clap/issues/3753)) - `ArgMatches::is_valid_arg` with `ArgMatches::{try_get_one,try_get_many}` ([#&#8203;3753](https://github.com/clap-rs/clap/issues/3753)) - `ArgMatches::occurrences_of` with `ArgMatches::value_source` or `ArgAction::Count` ([#&#8203;3797](https://github.com/clap-rs/clap/issues/3797)) - `ArgMatches::is_present` with `ArgMatches::contains_id` or `ArgAction::SetTrue` ([#&#8203;3797](https://github.com/clap-rs/clap/issues/3797)) - `ArgAction::StoreValue` with `ArgAction::Set` or `ArgAction::Append` ([#&#8203;3797](https://github.com/clap-rs/clap/issues/3797)) - `ArgAction::IncOccurrences` with `ArgAction::SetTrue` or `ArgAction::Count` ([#&#8203;3797](https://github.com/clap-rs/clap/issues/3797)) - *(derive)* `#[clap(parse(...))]` replaced with: ([#&#8203;3589](https://github.com/clap-rs/clap/issues/3589), [#&#8203;3794](https://github.com/clap-rs/clap/issues/3794)) - For default parsers (no `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`. - For `#[clap(parse(from_flag))]` replaced with `#[clap(action = ArgAction::SetTrue)]` ([#&#8203;3794](https://github.com/clap-rs/clap/issues/3794)) - For `#[clap(parse(from_occurrences))]` replaced with `#[clap(action = ArgAction::Count)]` though the field's type must be `u8` ([#&#8203;3794](https://github.com/clap-rs/clap/issues/3794)) - For `#[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). - For `#[clap(parse(try_from_str = ...)]`, replace it with `#[clap(value_parser = ...)]` - For most other cases, a type implementing `TypedValueParser` will be needed and specify it with `#[clap(value_parser = ...)]` ##### Features - Parsed, typed arguments via `Arg::value_parser` / `ArgMatches::{get_one,get_many}` ([#&#8203;2683](https://github.com/clap-rs/clap/issues/2683), [#&#8203;3732](https://github.com/clap-rs/clap/issues/3732)) - Several built-in `TypedValueParser`s available with an API open for expansion - `value_parser!(T)` macro for selecting a parser for a given type ([#&#8203;3732](https://github.com/clap-rs/clap/issues/3732)) and open to expansion via the `ValueParserFactory` trait ([#&#8203;3755](https://github.com/clap-rs/clap/issues/3755)) - `[&str]` is implicitly a value parser for possible values - All `ArgMatches` getters do not assume required arguments ([#&#8203;2505](https://github.com/clap-rs/clap/issues/2505)) - Add `ArgMatches::remove_*` variants to transfer ownership - Add `ArgMatches::try_*` variants to avoid panics for developer errors ([#&#8203;3621](https://github.com/clap-rs/clap/issues/3621)) - Add a `get_raw` to access the underlying `OsStr`s - `PathBuf` value parsers imply `ValueHint::AnyPath` for completions ([#&#8203;3732](https://github.com/clap-rs/clap/issues/3732)) - Explicit control over parsing via `Arg::action` ([#&#8203;3774](https://github.com/clap-rs/clap/issues/3774)) - `ArgAction::StoreValue`: existing `takes_value(true)` behavior - `ArgAction::IncOccurrences`: existing `takes_value(false)` behavior - `ArgAction::Help`: existing `--help` behavior - `ArgAction::Version`: existing `--version` behavior - `ArgAction::Set`: Overwrite existing values (like `Arg::multiple_occurrences` mixed with `Command::args_override_self`) ([#&#8203;3777](https://github.com/clap-rs/clap/issues/3777)) - `ArgAction::Append`: like `Arg::multiple_occurrences` ([#&#8203;3777](https://github.com/clap-rs/clap/issues/3777)) - `ArgAction::SetTrue`: Treat `--flag` as `--flag=true` ([#&#8203;3775](https://github.com/clap-rs/clap/issues/3775)) - Implies `Arg::default_value("false")` ([#&#8203;3786](https://github.com/clap-rs/clap/issues/3786)) - Parses `Arg::env` via `Arg::value_parser` - `ArgAction::SetFalse`: Treat `--flag` as `--flag=false` ([#&#8203;3775](https://github.com/clap-rs/clap/issues/3775)) - Implies `Arg::default_value("true")` ([#&#8203;3786](https://github.com/clap-rs/clap/issues/3786)) - Parses `Arg::env` via `Arg::value_parser` - `ArgAction::Count`: Treat `--flag --flag --flag` as `--flag=1 --flag=2 --flag=3` ([#&#8203;3775](https://github.com/clap-rs/clap/issues/3775)) - Implies `Arg::default_value("0")` ([#&#8203;3786](https://github.com/clap-rs/clap/issues/3786)) - Parses `Arg::env` via `Arg::value_parser` - *(derive)* Opt-in to new `Arg::value_parser` / `Arg::action` with either `#[clap(value_parser)]` ([#&#8203;3589](https://github.com/clap-rs/clap/issues/3589), [#&#8203;3742](https://github.com/clap-rs/clap/issues/3742)) / `#[clap(action)]` attributes ([#&#8203;3794](https://github.com/clap-rs/clap/issues/3794)) - Default `ValueParser` is determined by `value_parser!` ([#&#8203;3199](https://github.com/clap-rs/clap/issues/3199), [#&#8203;3496](https://github.com/clap-rs/clap/issues/3496)) - Default `ArgAction` is determine by a hard-coded lookup on the type ([#&#8203;3794](https://github.com/clap-rs/clap/issues/3794)) - `Command::multicall` is now stable for busybox-like programs and REPLs ([#&#8203;2861](https://github.com/clap-rs/clap/issues/2861), [#&#8203;3684](https://github.com/clap-rs/clap/issues/3684)) - `ArgMatches::{try_,}contains_id` for checking if there are values for an argument that mirrors the new `get_{one,many}` API ##### Fixes - Don't correct argument id in `default_value_ifs_os`([#&#8203;3815](https://github.com/clap-rs/clap/issues/3815)) *parser* - Set `ArgMatches::value_source` and `ArgMatches::occurrences_of` for external subcommands ([#&#8203;3732](https://github.com/clap-rs/clap/issues/3732)) - Use value delimiter for `Arg::default_missing_values` ([#&#8203;3761](https://github.com/clap-rs/clap/issues/3761), [#&#8203;3765](https://github.com/clap-rs/clap/issues/3765)) - Split`Arg::default_value` / `Arg::env` on value delimiters independent of whether `--` was used ([#&#8203;3765](https://github.com/clap-rs/clap/issues/3765)) - Allow applying defaults to flags ([#&#8203;3294](https://github.com/clap-rs/clap/issues/3294), 3775) - Defaults no longer satisfy `required` and its variants ([#&#8203;3793](https://github.com/clap-rs/clap/issues/3793)) ### [`v3.1.18`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3118---2022-05-10) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.17...v3.1.18) ##### Fixes - Fix deprecated `arg_enum!` for users migrating to clap3 ([#&#8203;3717](https://github.com/clap-rs/clap/issues/3717)) - Verify all `required_unless_present_all` arguments exist - Verify group members exist before processing group members ([#&#8203;3711](https://github.com/clap-rs/clap/issues/3711)) - *(help)* Use `...` when not enough `value_names` are supplied **gated behind `unstable-v4`** - Verify `required` is not used with conditional required settings ([#&#8203;3660](https://github.com/clap-rs/clap/issues/3660)) - Disallow more `value_names` than `number_of_values` ([#&#8203;2695](https://github.com/clap-rs/clap/issues/2695)) - *(parser)* Assert on unknown args when using external subcommands ([#&#8203;3703](https://github.com/clap-rs/clap/issues/3703)) - *(parser)* Always fill in `""` argument for external subcommands ([#&#8203;3263](https://github.com/clap-rs/clap/issues/3263)) - *(derive)* Detect escaped external subcommands that look like built-in subcommands ([#&#8203;3703](https://github.com/clap-rs/clap/issues/3703)) - *(derive)* Leave `Arg::id` as `verbatim` casing ([#&#8203;3282](https://github.com/clap-rs/clap/issues/3282)) ### [`v3.1.17`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3117---2022-05-06) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.16...v3.1.17) ##### Fixes - Allow value names for `arg!` macro to have dashes when quoted, like longs ### [`v3.1.16`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3116---2022-05-06) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.15...v3.1.16) ##### Fixes - *(parser)* `Arg::exclusive` overrides `Arg::required`, like other conflicts - *(error)* Don't duplicate arguments in usage - *(error)* Don't show hidden arguments in conflict error usage - *(help)* New `help_template` variable `{name}` to fix problems with `{bin}` - *(help)* Don't wrap URLs **gated behind `unstable-v4`** - Leading dashes in `Arg::long` are no longer allowed - *(help)* Use `Command::display_name` in the help title rather than `Command::bin_name` ### [`v3.1.15`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3115---2022-05-02) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.14...v3.1.15) ##### Fixes - *(error)* Render actual usage for unrecognized subcommands - *(multicall)* Improve bad command error - *(multicall)* Always require a multicall command - *(multicall)* Disallow arguments on multicall parent command - *(multicall)* More consistent with rest of clap errors ### [`v3.1.14`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3114---2022-05-01) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.13...v3.1.14) ##### Fixes - Panic when calling `Command::build` with a required positional argument nested several layers in subcommands ### [`v3.1.13`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3113---2022-04-30) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.12...v3.1.13) ##### Fixes - Help subcommand and `Command::write_help` now report required arguments in usage in more circumstances - Unknown subcommand for help subcommand flag now reports an error with more context - More details reported when using `debug` feature - Allow disabling `color` feature with `debug` feature enabled ### [`v3.1.12`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3112---2022-04-22) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.11...v3.1.12) ##### Fixes - Regression in 3.1.11 where the (output) streams were crossed ### [`v3.1.11`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3111---2022-04-22) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.10...v3.1.11) ##### Fixes - Implied conflicts override `Arg::required`, making the behavior consistent with how we calculate conflicts for error reporting - Members of a mutually exclusive `ArgGroup` override `Arg::required`, making the behavior consistent with how we calculate conflicts for error reporting - `Arg::overrides_with` always override `Arg::required`, not just when the parser processes an override ### [`v3.1.10`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3110---2022-04-19) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.9...v3.1.10) ##### Features - Expose `Command::build` for custom help generation or other command introspection needs ### [`v3.1.9`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#319---2022-04-15) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.8...v3.1.9) ##### Fixes - Pin the `clap_derive` version so a compatible version is always used with `clap` ### [`v3.1.8`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#318---2022-04-01) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.7...v3.1.8) ##### Fixes - Add `Debug` impls to more types ### [`v3.1.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#317---2022-03-31) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.6...v3.1.7) ##### Fixes - *(derive)* Abort, rather than ignore, when deriving `ArgEnum` with non-unit unskipped variants ### [`v3.1.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#316---2022-03-07) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.5...v3.1.6) ##### Fixes - Don't panic when validating delimited defaults ([#&#8203;3541](https://github.com/clap-rs/clap/issues/3541)) - Make it clearer that `cargo` feature is needed - Documentation improvements ### [`v3.1.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#315---2022-03-02) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.4...v3.1.5) ##### Fixes - Dependency upgrade ### [`v3.1.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#314---2022-03-02) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.3...v3.1.4) ##### Features - *(help)* Show `PossibleValue::help` in long help (`--help`) **(gated behind `unstable-v4`)** ([#&#8203;3312](https://github.com/clap-rs/clap/issues/3312)) ### [`v3.1.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#313---2022-02-28) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.2...v3.1.3) ##### Fixes - Don't panic when validating delimited defaults ([#&#8203;3514](https://github.com/clap-rs/clap/issues/3514)) ### [`v3.1.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#312---2022-02-23) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.1...v3.1.2) ##### Fixes - *(derive)* Allow other attribute with a subcommand that has subcommands ##### Documentation - *(examples)* List example topics - *(derive)* Clarify syntax and relation to builder API ### [`v3.1.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3118---2022-05-10) [Compare Source](https://github.com/clap-rs/clap/compare/v3.1.0...v3.1.1) ##### Fixes - Fix deprecated `arg_enum!` for users migrating to clap3 ([#&#8203;3717](https://github.com/clap-rs/clap/issues/3717)) - Verify all `required_unless_present_all` arguments exist - Verify group members exist before processing group members ([#&#8203;3711](https://github.com/clap-rs/clap/issues/3711)) - *(help)* Use `...` when not enough `value_names` are supplied **gated behind `unstable-v4`** - Verify `required` is not used with conditional required settings ([#&#8203;3660](https://github.com/clap-rs/clap/issues/3660)) - Disallow more `value_names` than `number_of_values` ([#&#8203;2695](https://github.com/clap-rs/clap/issues/2695)) - *(parser)* Assert on unknown args when using external subcommands ([#&#8203;3703](https://github.com/clap-rs/clap/issues/3703)) - *(parser)* Always fill in `""` argument for external subcommands ([#&#8203;3263](https://github.com/clap-rs/clap/issues/3263)) - *(derive)* Detect escaped external subcommands that look like built-in subcommands ([#&#8203;3703](https://github.com/clap-rs/clap/issues/3703)) - *(derive)* Leave `Arg::id` as `verbatim` casing ([#&#8203;3282](https://github.com/clap-rs/clap/issues/3282)) ### [`v3.1.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#310---2022-02-16) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.14...v3.1.0) ##### Compatibility Changes in behavior of note that are not guaranteed to be compatible across releases: - *(help)* `help` subcommand shows long help like `--help`, rather than short help (`-h`), deprecated `clap::AppSettings::UseLongFormatForHelpSubcommand` ([#&#8203;3440](https://github.com/clap-rs/clap/issues/3440)) - *(help)* Pacman-style subcommands are now ordered the same as usage errors ([#&#8203;3470](https://github.com/clap-rs/clap/issues/3470)) - *(help)* Pacman-style subcommands use standard alternate syntax in usage ([#&#8203;3470](https://github.com/clap-rs/clap/issues/3470)) ##### Deprecations - `clap::Command` is now preferred over `clap::App` ([#&#8203;3089](https://github.com/clap-rs/clap/issues/3089) in [#&#8203;3472](https://github.com/clap-rs/clap/issues/3472)) - `clap::command!` is now preferred over `clap::app_from_crate` ([#&#8203;3089](https://github.com/clap-rs/clap/issues/3089) in [#&#8203;3474](https://github.com/clap-rs/clap/issues/3474)) - `clap::CommandFactory::command` is now preferred over `clap::IntoApp::into_app` ([#&#8203;3089](https://github.com/clap-rs/clap/issues/3089) in [#&#8203;3473](https://github.com/clap-rs/clap/issues/3473)) - *(help)* `help` subcommand shows long help like `--help`, rather than short help (`-h`), deprecated `clap::AppSettings::UseLongFormatForHelpSubcommand` ([#&#8203;3440](https://github.com/clap-rs/clap/issues/3440)) - *(error)* Deprecate `clap::AppSettings::WaitOnError`, leaving it to the user to implement - *(validation)* `clap::Command::subcommand_required(true).arg_required_else_help(true)` is now preferred over `clap::AppSettings::SubcommandRequiredElseHelp` ([#&#8203;3280](https://github.com/clap-rs/clap/issues/3280)) - *(builder)* `clap::AppSettings` are nearly all deprecated and replaced with builder methods and getters ([#&#8203;2717](https://github.com/clap-rs/clap/issues/2717)) - *(builder)* `clap::ArgSettings` is deprecated and replaced with builder methods and getters ([#&#8203;2717](https://github.com/clap-rs/clap/issues/2717)) - *(builder)* `clap::Arg::id` and `clap::ArgGroup::id` are now preferred over `clap::Arg::name` and `clap::ArgGroup::name` ([#&#8203;3335](https://github.com/clap-rs/clap/issues/3335)) - *(help)* `clap::Command::next_help_heading` is now preferred over `clap::Command::help_heading` ([#&#8203;1807](https://github.com/clap-rs/clap/issues/1807), [#&#8203;1553](https://github.com/clap-rs/clap/issues/1553)) - *(error)* `clap::error::ErrorKind` is now preferred over `clap::ErrorKind` ([#&#8203;3395](https://github.com/clap-rs/clap/issues/3395)) - *(error)* `clap::Error::kind()` is now preferred over `clap::Error::kind` - *(error)* `clap::Error::context()` is now preferred over `clap::Error::info` ([#&#8203;2628](https://github.com/clap-rs/clap/issues/2628)) Note: All items deprecated in 3.0.0 are now hidden in the documentation. ([#&#8203;3458](https://github.com/clap-rs/clap/issues/3458)) ##### Features - *(matches)* Add `clap::ArgMatches::value_source` to determine what insert the value ([#&#8203;1345](https://github.com/clap-rs/clap/issues/1345)) - *(help)* Override derived display order with `clap::Command::next_display_order` ([#&#8203;1807](https://github.com/clap-rs/clap/issues/1807)) - *(error)* Show possible values when an argument doesn't have a value ([#&#8203;3320](https://github.com/clap-rs/clap/issues/3320)) - *(error)* New `clap::Error::context` API to open the door for fully-custom error messages ([#&#8203;2628](https://github.com/clap-rs/clap/issues/2628)) - *(error)* `clap::error::ErrorKind` now implements `Display` ##### Fixes - *(builder)* Some functions were renamed for consistency and fixing spelling issues - *(builder)* Allow `clap::Command::color` to override previous calls ([#&#8203;3449](https://github.com/clap-rs/clap/issues/3449)) - *(parse)* Propagate globals with multiple subcommands ([#&#8203;3428](https://github.com/clap-rs/clap/issues/3428)) - *(validation)* Give `ArgRequiredElseHelp` precedence over `SubcommandRequired` ([#&#8203;3456](https://github.com/clap-rs/clap/issues/3456)) - *(validation)* Default values no longer count as "present" for conflicts, requires, `clap::Command::arg_required_else_help`, etc ([#&#8203;3076](https://github.com/clap-rs/clap/issues/3076), [#&#8203;1264](https://github.com/clap-rs/clap/issues/1264)) - *(assert)* Report invalid defaults ([#&#8203;3202](https://github.com/clap-rs/clap/issues/3202)) - *(help)* Clarify how to handle `-h` conflicts ([#&#8203;3403](https://github.com/clap-rs/clap/issues/3403)) - *(help)* Make it easier to debug the addition of help flags ([#&#8203;3425](https://github.com/clap-rs/clap/issues/3425)) - *(help)* Pacman-style subcommands are now separated with spaces ([#&#8203;3470](https://github.com/clap-rs/clap/issues/3470)) - *(help)* Pacman-style subcommands are now ordered the same as usage errors ([#&#8203;3470](https://github.com/clap-rs/clap/issues/3470)) - *(help)* Pacman-style subcommands use standard alternate syntax in usage ([#&#8203;3470](https://github.com/clap-rs/clap/issues/3470)) - *(error)* Be consistent in showing of required attributes between errors / usage ([#&#8203;3390](https://github.com/clap-rs/clap/issues/3390)) - *(error)* Show user's order of possible values, like in `--help` ([#&#8203;1549](https://github.com/clap-rs/clap/issues/1549)) - *(error)* Allow customizing error type in `clap::error::Result` ([#&#8203;3395](https://github.com/clap-rs/clap/issues/3395)) ##### Performance - *(error)* Reduced stack size of `clap::Error` ([#&#8203;3395](https://github.com/clap-rs/clap/issues/3395)) ##### Documentation - *(builder)* Correct data take accepted for `clap::Arg::validator` - *(derive)* Clarify `parse` attribute - *(tutorial)* Demonstrate custom parsing - *(example)* Consistently list out required feature flags ([#&#8203;3448](https://github.com/clap-rs/clap/issues/3448)) ### [`v3.0.14`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3014---2022-02-01) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.13...v3.0.14) ##### Features - Added `ArgMatches::args_present()` to check if any args are present - Added `Error::kind()` as we work to deprecate direct member access for `Error` - Added `App::get_version` - Added `App::get_long_version` - Added `App::get_author` - Added `App::get_subcommand_help_heading` - Added `App::get_subcommand_value_name` - Added `App::get_after_help` - Added `App::get_after_long_help` ##### Performance - Misc binary size reductions ### [`v3.0.13`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3013---2022-01-26) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.12...v3.0.13) ##### Fixes - Show optional flag values wrapped in `[]` ### [`v3.0.12`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3012---2022-01-24) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.11...v3.0.12) ##### Features - *(derive)* Support for `default_value_os_t` ### [`v3.0.11`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3011---2022-01-24) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.10...v3.0.11) ##### Fixes - Ensure conflicts work when they target a group with a default value ### [`v3.0.10`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3010---2022-01-18) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.9...v3.0.10) ##### Fixes - Resolve `panic!` from v3.0.8 when using `global_setting(PropagateVersion)`. ### [`v3.0.9`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#309---2022-01-17) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.8...v3.0.9) ##### Features - Added `App::find_subcommand_mut` ### [`v3.0.8`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#308---2022-01-17) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.7...v3.0.8) ##### Fixes - Respected `DisableColoredHelp` on `cmd help help` - Provide a little more context when completing arguments for `cmd help` - Provide more context for some asserts - Small documentation improvements ### [`v3.0.7`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#307---2022-01-12) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.6...v3.0.7) ##### Fixes - Shift more asserts from parsing to `App` building (ie will now run in `App::debug_assert`) **derive** - Documentation fixes ### [`v3.0.6`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#306---2022-01-10) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.5...v3.0.6) ##### Fixes **derive** - Don't assume user does `use clap::ArgEnum` ([#&#8203;3277](https://github.com/clap-rs/clap/issues/3277)) - Documentation fixes ### [`v3.0.5`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#305---2022-01-05) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.4...v3.0.5) ##### Fixes - Provide hack to workaround [inability to detect external subcommands aliasing when escaped](https://github.com/clap-rs/clap/issues/3263) ([#&#8203;3264](https://github.com/clap-rs/clap/issues/3264)) **docs:** - Cleaned up code blocks in tutorials ([#&#8203;3261](https://github.com/clap-rs/clap/issues/3261)) - Clean up quotes in `ArgMatches` asserts - List correct replacement for deprecated `Parser::from_clap` ([#&#8203;3257](https://github.com/clap-rs/clap/issues/3257)) ### [`v3.0.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#304---2022-01-04) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.3...v3.0.4) ##### Features - For very limited cases, like `cargo`, expose `ArgMatches::is_valid_arg` to avoid panicing on undefined arguments ### [`v3.0.3`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#303---2022-01-04) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.2...v3.0.3) ##### Fixes - Specify cause of debug assert failure ### [`v3.0.2`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#302---2022-01-04) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.1...v3.0.2) ##### Fixes - Ignore `Last` when checking hyphen values (see [#&#8203;3249](https://github.com/clap-rs/clap/issues/3249) for details) - Help catch bugs with `#[must_use]` ### [`v3.0.1`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#3014---2022-02-01) [Compare Source](https://github.com/clap-rs/clap/compare/v3.0.0...v3.0.1) ##### Features - Added `ArgMatches::args_present()` to check if any args are present - Added `Error::kind()` as we work to deprecate direct member access for `Error` - Added `App::get_version` - Added `App::get_long_version` - Added `App::get_author` - Added `App::get_subcommand_help_heading` - Added `App::get_subcommand_value_name` - Added `App::get_after_help` - Added `App::get_after_long_help` ##### Performance - Misc binary size reductions ### [`v3.0.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#300---2021-12-31) [Compare Source](https://github.com/clap-rs/clap/compare/v2.34.0...v3.0.0) **Note:** clap v3 has been in development for several years and has changed hands multiple times. Unfortunately, our changelog might be incomplete, whether in changes or their motivation. ##### Highlights A special thanks to the maintainers, contributors, beta users, and sponsors who have helped along this journey, especially kbknapp. **[StructOpt](https://docs.rs/structopt/) Integration** [StructOpt](https://docs.rs/structopt/) provides a serde-like declarative approach to defining your parser. The main benefits we've seen so far from integrating are: - Tighter feedback between the design of clap and the derives - More universal traits. Crates exist for common CLI patterns ([example](https://github.com/rust-cli/clap-verbosity-flag)) and we've re-designed the `StructOpt` traits so crates built on clap3 can be reused not just with other derives but also people using the builder API. People can even hand implement these so people using the builder API won't have the pay the cost for derives. **Custom Help Headings** Previously, clap automatically grouped arguments in the help as either `ARGS`, `FLAGS`, `OPTIONS`, and `SUBCOMMANDS`. You can now override the default group with `Arg::help_heading` and `App::subcommand_help_heading`. To apply a heading to a series of arguments, you can set `App::help_heading`. **Deprecations** While a lot of deprecations have been added to clean up the API (overloaded meaning of `Arg::multiple`) or make things more consistent, some particular highlights are: - `clap_app!` has been deprecated in favor of the builder API with `arg!` ([clap-rs/clap#2835](https://github.com/clap-rs/clap/issues/2835)) - `Arg::from_usage` has been deprecated in favor of `arg!` ([clap-rs/clap#3087](https://github.com/clap-rs/clap/issues/3087)) - [Porting example](https://github.com/clap-rs/clap/commit/4c4a2b86a08ef9e2d63010aab4909dd5a013dfb0) - The YAML API has been deprecated in favor the builder or derive APIs ([clap-rs/clap#3087](https://github.com/clap-rs/clap/issues/3087)) ##### Migrating **From clap v2** 1. Add CLI tests, `-h` and `--help` output at a minimum (recommendation: [trycmd](https://docs.rs/trycmd/) for snapshot testing) 2. Update your dependency 1. *If you use `no-default-features`:* add the `std` feature 3. Resolve compiler errors 4. Resolve behavior changes 1. Refactor your `App` creation to a function and add a test similar to the one below, resolving any of its assertions 2. Look over the "subtle changes" under BREAKING CHANGES 3. *If using builder:* test your application under various circumstances to see if `ArgMatches` asserts regarding `AllowInvalidUtf8`. 5. *At your leisure:* resolve deprecation notices Example test: ```rust fn app() -> clap::App<'static> { ... } #[test] fn verify_app() { app().debug_assert(); } ``` **From structopt 0.3.25** 1. Add CLI tests, `-h` and `--help` output at a minimum (recommendation: [trycmd](https://docs.rs/trycmd/) for snapshot testing) 2. Replace your dependency from `structopt = "..."` to `clap = { version = "3.0", features = ["derive"] }` 1. *If you use `no-default-features`:* add the `std` feature 3. Resolve compiler errors, including 1. Update your `use` statements from `structopt` and `structopt::clap` to `clap` 4. Resolve behavior changes 1. Add a test similar to the one below, resolving any of its assertions 2. Look over the "subtle changes" under BREAKING CHANGES 5. *At your leisure:* resolve deprecation notices Example test: ```rust #[derive(clap::StructOpt)] struct Args { ... } #[test] fn verify_app() { use clap::IntoApp; Args::into_app().debug_assert() } ``` **From clap v3.0.0-beta.5** 1. Add CLI tests, `-h` and `--help` output at a minimum (recommendation: [trycmd](https://docs.rs/trycmd/) for snapshot testing) 2. Update your dependency 1. Add in `derive`, `env`, `cargo`, or `unicode` feature flags as needed 3. Resolve compiler errors 1. *If you use `yaml`, `clap_app!`, or usage parser:* revert any changes you made for clap3 2. Change `Arg::about` `Arg::long_about` back to `help` and `long_help` and change `PossibleValue::about` to `help` ([clap-rs/clap#3075](https://github.com/clap-rs/clap/issues/3075)) 3. Change `AppSettings::HelpRequired` to `AppSettings::HelpExpected` 4. Change `PossibleValue::hidden` to `PossibleValue::hide` 5. Change `App::subcommand_placeholder` to `App::subcommand_value_name` / `App::subcommand_help_heading` 4. Resolve behavior changes 1. Add the above listed test appropriate for your application and resolve any problems it reports 2. *If using `derive`:* see the structopt breaking changes section for `Vec` changes 3. *If using builder:* test your application under various circumstances to see if `ArgMatches` asserts regarding `AllowInvalidUtf8`. 5. *At your leisure:* resolve deprecation notices ##### BREAKING CHANGES **From clap 2** Subtle changes (i.e. compiler won't catch): - `AppSettings::UnifiedHelpMessage` is now default behaviour - `{flags}` and `{unified}` will assert if present in `App::help_template` - See [clap-rs/clap#2807](https://github.com/clap-rs/clap/issues/2807) - `AppSettings::EnableColoredHelp` is now the default behavior but can be opted-out with `AppSettings::DisableColoredHelp` ([clap-rs/clap#2806](https://github.com/clap-rs/clap/issues/2806)) - `App::override_usage` no longer implies a leading `\t`, allowing multi lined usages - `Arg::require_equals` no longer implies `ArgSettings::ForbidEmptyValues` ([#&#8203;2233](https://github.com/clap-rs/clap/issues/2233)) - `Arg::require_delimiter` no longer implies `ArgSettings::TakesValue` and `ArgSettings::UseValueDelimiter` ([#&#8203;2233](https://github.com/clap-rs/clap/issues/2233)) - `Arg::env`, `Arg::env_os`, `Arg::last`, `Arg::require_equals`, `Arg::allow_hyphen_values`, `Arg::hide_possible_values`, `Arg::hide_default_value`, `Arg::hide_env_values`, `Arg::case_insensitive` and `Arg::multiple_values` no longer imply `ArgSettings::TakesValue` ([#&#8203;2233](https://github.com/clap-rs/clap/issues/2233)) - `ArgMatches::is_present` no longer checks subcommand names - Some env variable values are now considered false for flags, not just "not-present" ([clap-rs/clap#2539](https://github.com/clap-rs/clap/issues/2539)) - Changed `...`s meaning in usage parser. Before, it always meant `multiple` which is still true for `--option [val]...`. Now `[name]... --option [val]` results in `ArgSettings::MultipleOccurrences`. - Usage exit code changed from `1` to `2` ([clap-rs/clap#1327](https://github.com/clap-rs/clap/issues/1327)) - Reject `--foo=bar` when `takes_value(false)` ([clap-rs/clap#1543](https://github.com/clap-rs/clap/issues/1543)) - No longer accept an arbitrary number of `-` for long arguments (`-----long`) Easier to catch changes: - When using `no-default-features`, you now have to specify the `std` feature (reserved for future work) - Gated env support behind `env` feature flag - Impacts `Arg::env`, `Arg::env_os`, `Arg::hide_env_values`, `ArgSettings::HideEnvValues` - See [clap-rs/clap#2694](https://github.com/clap-rs/clap/pull/2694) - Gated crate information behind `cargo` feature flag - Impacts `crate_name!`, `crate_version!`, `crate_authors!`, `crate_description!`, `app_from_crate!` - `AppSettings::StrictUtf8` is now default behaviour and asserts if `AppSettings::AllowInvalidUtf8ForExternalSubcommands` and `ArgSettings::AllowInvalidUtf8` and `ArgMatches::value_of_os` aren't used together - `AppSettings::AllowInvalidUtf8` has been removed - [clap-rs/clap#751](https://github.com/clap-rs/clap/issues/751) - `Arg::short` and `Arg::value_delimiter` now take a `char` instead of a `&str` - `ArgMatches` panics on unknown arguments - Removed `VersionlessSubcommands`, making it the default (see [clap-rs/clap#2812](https://github.com/clap-rs/clap/issues/2812)) - Completion generation has been split out into [clap\_complete](./clap_complete). - Removed `ArgSettings::EmptyValues` in favor of `ArgSettings::ForbidEmptyValues` - Validator signatures have been loosed: - `Arg::validator` now takes first argument as `Fn(&str) -> Result<O, E: ToString>` instead of `Fn(String) -> Result<(), String>` - `Arg::validator_os` now takes first argument as `Fn(&OsStr) -> Result<O, OsString>` instead of `Fn(&OsStr) -> Result<(), OsString>` - `Arg::value_name` now sets, rather than appends (see [clap-rs/clap#2634](https://github.com/clap-rs/clap/issues/2634)) - Upgrade `yaml-rust` from 0.3 to 0.4 - Replaced `ArgGroup::from(BTreeMap)` to `ArgGroup::from(yaml)` - Replaced `ArgMatches::usage` with `App::generate_usage` - Replaced `Arg::settings` with `Arg::setting(Setting1 | Setting2)` - `App` and `Arg` now need only one lifetime - Removed deprecated `App::with_defaults`, replaced with `app_from_crate` - Removed deprecated `AppSettings::PropagateGlobalValuesDown` (now the default) - Some `App` functions, like `App::write_help` now take `&mut self` instead of `&self` - `Error::message` is now private, use `Error::to_string` - `Arg::default_value_if`, `Arg::default_value_if_os`, `Arg::default_value_ifs`, `Arg::default_value_ifs_os` now takes the default value parameter as an option ([clap-rs/clap#1406](https://github.com/clap-rs/clap/issues/1406)) - Changed `App::print_help` & `App::print_long_help` to now return `std::io::Result` - Changed `App::write_help` & `App::write_long_help` to now return `std::io::Result` - Changed `Arg::index`, `Arg::number_of_values`, `Arg::min_values`, `Arg::max_values` to taking `usize` instead of u64 - Changed `Error::info` to type `Vec<String>` instead of `Option<Vec<String>>` - Changed `ArgMatches::subcommand` to now return `Option<(&str, &ArgMatches)>` - Renamed `ErrorKind::MissingArgumentOrSubcommand` to `ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand` - Renamed `ErrorKind::HelpDisplayed` to `ErrorKind::DisplayHelp` - Renamed `ErrorKind::VersionDisplayed` to `ErrorKind::DisplayVersion` - Added `#[non_exhaustive]` to `clap::{ValueHint, ErrorKind, AppSettings, ArgSettings}` ([clap-rs/clap#3167](https://github.com/clap-rs/clap/pull/3167)) **From structopt 0.3.25** - By default, the `App` isn't initialized with crate information anymore. Now opt-in via `#[clap(author)]`, `#[clap(about)]`, `#[clap(version)]` ([clap-rs/clap#3034](https://github.com/clap-rs/clap/issues/3034)) - `#[clap(default_value)]` is replaced with `#[clap(default_value_t)]` ([clap-rs/clap#1694](https://github.com/clap-rs/clap/issues/1694)) - Subcommands nested under subcommands now needs a `#[clap(subcommand)]` attribute ([clap-rs/clap#2587](https://github.com/clap-rs/clap/pull/2587)) - `Vec<_>` and `Option<Vec<_>>` have changed from `multiple` to `multiple_occurrences` On top of the clap 2 changes ##### Performance **From clap 2** - Split out non-default `unicode` feature flag for faster builds and smaller binaries for ASCII-only CLIs. - Split out non-default `env` feature flag for faster builds and smaller binaries. ##### Features **From clap 2** - Integration of `structopt::StructOpt` via `clap::Parser` (requires `derive` feature flag) - Custom help headings - `App::help_heading` (apply to all future args) - `Arg::help_heading` (apply to current arg) - `App::subcommand_help_heading` along with `App::subcommand_value_name` (apply to subcommands) - See [clap-rs/clap#805](https://github.com/clap-rs/clap/issues/805) - `AppSettings::UnifiedHelpMessage` is now default behaviour ([clap-rs/clap#2807](https://github.com/clap-rs/clap/issues/2807)) - Deriving of `ArgEnum` for generating `Arg::possible_values` (requires `derive` feature flag) - Disable built-in help/version behavior with `AppSettings::NoAutoHelp` and `AppSettings::NoAutoVersion` - Change an existing arg with new builder method `mut_arg` (particularly helpful for `--help` and `--version`) - Provide extra context in long help messages (`--help`) with `before_long_help` and `after_long_help` ([clap-rs/clap#1903](https://github.com/clap-rs/clap/issues/1903)) - Detect missing help descriptions via debug asserts by enabling `AppSettings::HelpExpected` - Aliases for short flags ([clap-rs/clap#1896](https://github.com/clap-rs/clap/issues/1896)) - Validate UTF-8 values, rather than panicing during `ArgMatches::value_of` thanks to `AppSettings::AllowInvalidUtf8ForExternalSubcommands` and `ArgSettings::AllowInvalidUtf8` - Debug builds will assert when the `ArgMatches` calls do not match the UTF-8 setting. - See [clap-rs/clap#751](https://github.com/clap-rs/clap/issues/751) - `clap::PossibleValue` to allow - Hiding ([clap-rs/clap#2756](https://github.com/clap-rs/clap/issues/2756)) - Completion help for possible values for args ([clap-rs/clap#2731](https://github.com/clap-rs/clap/issues/2731)) - Allow arguments to conflict with all others via `Arg::exclusive` ([clap-rs/clap#1583](https://github.com/clap-rs/clap/issues/1583)) - Validate arguments with a regex (required `regex` feature flag) - See [clap-rs/clap](https://github.com/clap-rs/clap/issues/1968) - `Arg::default_missing_value` for cases like `--color[=<WHEN>]` ([clap-rs/clap#1587](https://github.com/clap-rs/clap/pull/1587)) - `clap::App::color` / `clap::ColorChoice` to specify color setting for the app - Custom error reporting with `App::error` - `App::debug_assert` test helper - Replace `Arg::multiple(bool)` with `Arg::multiple_values` / `Arg::multiple_occurrences` - Positionals can be either - Added support for flag subcommands like pacman ([clap-rs/clap#1361](https://github.com/clap-rs/clap/issues/1361)) - Partial parsing via `AppSettings::IgnoreErrors` ([clap-rs/clap#1880](https://github.com/clap-rs/clap/issues/1880)) - Enable `cmd help` to print long help (`--help` instead of `-h`) with `AppSettings::UseLongFormatForHelpSubcommand` ([clap-rs/clap#2435](https://github.com/clap-rs/clap/issues/2435)) - Allow long arg abbreviations like we do with subcommands via `AppSettings::InferLongArgs` ([clap-rs/clap#2435](https://github.com/clap-rs/clap/issues/2435)) - Detect subcommands among positional arguments with `AppSettings::SubcommandPrecedenceOverArg` - Give completion scripts hints with `Arg::value_hint` ([clap-rs/clap#1793](https://github.com/clap-rs/clap/pull/1793)) - Allow unsetting defaults with - `Arg::default_value_if`, `Arg::default_value_if_os`, `Arg::default_value_ifs`, `Arg::default_value_ifs_os` ([clap-rs/clap#1406](https://github.com/clap-rs/clap/issues/1406)) - Interpret some env variable values as `false` for flags, in addition to "not-present" ([clap-rs/clap#2539](https://github.com/clap-rs/clap/issues/2539)) - `n`, `no`, `f`, `false`, `off`, `0` - Added `arg!` macro for creating an `Arg` from a compile-time usage parser - *(Experimental)* Busybox-like multi-call support - See `AppSettings::Multicall` behind `unstable-multicall` feature flag - See [clap-rs/clap#1120](https://github.com/clap-rs/clap/issues/1120) - *(Experimental)* Alias an argument to anything group of arguments - See `App::replace` behind `unstable-replace` feature flag - See [clap-rs#1603](https://github.com/clap-rs/clap/issues/1603) - *(Experimental)* Grouping of multiple values within multiple occurrences - See `ArgMatches::grouped_values_of` behind `unstable-grouped` feature flag - See [clap-rs/clap#1026](https://github.com/clap-rs/clap/issues/1026) **From structopt 0.3.25** - Allow defaulting with native types via new `default_value_t [= <expr>]` attribute ([clap-rs/clap#1694](https://github.com/clap-rs/clap/issues/1694)) - New `update` API - New `arg_enum` attribute for integrating with `ArgEnum` trait On top of the clap 2 changes ##### Fixes **From clap 2** - Correctly handle colored output on Windows - Only generate version flags when `App::version`, `App::long_version` are set (see [clap-rs/clap#2812](https://github.com/clap-rs/clap/issues/2812)) - General completion script improvements - Limited default help text wrapping to 100 when `wrap_help` feature is not enabled - Be more specific than `Arg::multiple` with `Arg::multiple_values` and `Arg::multiple_occurrences` - `app_from_crate!` defaults to separating multiple authors with `", "` - Ensure all examples work - `IgnoreCase` is now unicode aware (requires `unicode` feature flag) - Always respect `ColorChoice::Never`, even if that means we skip colors in some cases - `ArgMatches` panics on unknown arguments - Gracefully handle empty `authors` field in `Cargo.toml` with `app_from_crate` - Do not show `--help` in `cmd help` with `DisableHelpFlag` ([clap-rs/clap#3169](https://github.com/clap-rs/clap/pull/3169)) - Do not show `--help` in `cmd help help` that doesn't work ([clap-rs/clap#3169](https://github.com/clap-rs/clap/pull/3169)) **From structopt 0.3.25** - Support `SubcommandsNegateReqs` by allowing required `Option<_>`s ([clap-rs/clap#2255](https://github.com/clap-rs/clap/issues/2255)) - Infer `AllowInvalidUtf8` based on parser ([clap-rs/clap#751](https://github.com/clap-rs/clap/issues/2255)) - Gracefully handle empty `authors` field in `Cargo.toml` - Don't panic with `default_value_os` but treat it like `default_value` ([clap-rs/clap#3031](https://github.com/clap-rs/clap/issues/3031)) - When using `flatten` and `subcommand`, ensure our doc comment always overrides the nested container's doc comment, whether it has only `about` or `about` and `long_about` ([clap-rs/clap#3175](]https://github.com/clap-rs/clap/pull/3175)) On top of the clap 2 changes ##### Minimum Required Rust - As of this release, `clap` requires `rustc 1.54.0` or greater. ### [`v2.34.0`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#2340---2021-11-30) [Compare Source](https://github.com/clap-rs/clap/compare/v2.33.4...v2.34.0) - Updates to Rust 2018 edition and bumps the MSRV to Rust 1.46 ### [`v2.33.4`](https://github.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#2334---2021-11-29) [Compare Source](https://github.com/clap-rs/clap/compare/v2.33.3...v2.33.4) ##### Bug Fixes - **prevents `panic`:** swallows broken pipe errors on error output ([7a729bc4](https://github.com/kbknapp/clap-rs/commit/7a729bc4df2646b05f6bf15f001124cd39d076ce)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNTcuNCIsInVwZGF0ZWRJblZlciI6IjQxLjE2OS4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin renovate/clap-4.x:renovate/clap-4.x
git switch renovate/clap-4.x

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff renovate/clap-4.x
git switch renovate/clap-4.x
git rebase main
git switch main
git merge --ff-only renovate/clap-4.x
git switch renovate/clap-4.x
git rebase main
git switch main
git merge --no-ff renovate/clap-4.x
git switch main
git merge --squash renovate/clap-4.x
git switch main
git merge --ff-only renovate/clap-4.x
git switch main
git merge renovate/clap-4.x
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lilly/VipTraceRouter#4
No description provided.