-
Notifications
You must be signed in to change notification settings - Fork 1
Update Rust crate clap to v4 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
renovate
wants to merge
1
commit into
master
Choose a base branch
from
renovate/clap-4.x
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5751b38 to
a2ce8a4
Compare
b49b80b to
1cd694c
Compare
57e2b44 to
d0faa37
Compare
4d8a7cf to
0ead75c
Compare
8cbd922 to
83f6744
Compare
54aeba8 to
efaf057
Compare
30316b5 to
36573bc
Compare
36573bc to
59eace6
Compare
79007ac to
ef51dd4
Compare
ef51dd4 to
8a22da4
Compare
784a3c9 to
9bb366e
Compare
e114239 to
a19bde6
Compare
a19bde6 to
e535de5
Compare
e535de5 to
83c2325
Compare
20f429c to
ae64c8f
Compare
ae64c8f to
6ac9c1c
Compare
eb9d9ef to
a555e0e
Compare
23242c1 to
66fb88b
Compare
66fb88b to
c9975a6
Compare
c9975a6 to
7c6a52f
Compare
7c6a52f to
aa6511a
Compare
aa6511a to
b42b10e
Compare
b42b10e to
4a4def4
Compare
4a4def4 to
038abfb
Compare
038abfb to
f52e50f
Compare
f52e50f to
b4e2a83
Compare
b4e2a83 to
cf3a417
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
3.2.25->4.0.0Release Notes
clap-rs/clap (clap)
v4.5.53Compare Source
v4.5.52Compare Source
Fixes
args_conflicts_with_subcommandsconflicts with anArgGroupv4.5.51Compare Source
Fixes
ArgAction::Countv4.5.50Compare Source
Features
CowwhereStringand&strare acceptedv4.5.49Compare Source
Fixes
v4.5.48Compare Source
Documentation
typed_derivecookbook entryv4.5.47Compare Source
Features
impl FromArgMatches for ()impl Args for ()impl Subcommand for ()impl FromArgMatches for Infallibleimpl Subcommand for InfallibleFixes
clapv4.5.46Compare Source
Features
StyledStr::push_strv4.5.45Compare Source
Fixes
ValueEnumvariants now use the full doc comment, not summary, forPossibleValue::helpv4.5.44Compare Source
Features
Command::mut_subcommandsv4.5.43Compare Source
Fixes
v4.5.42Compare Source
Fixes
--helpv4.5.41Compare Source
Features
Styles::contextandStyles::context_valueto customize the styling of[default: value]like notes in the--helpv4.5.40Compare Source
Features
arg!()macro (e.g.arg!("check-config": ...))v4.5.39Compare Source
Fixes
v4.5.38Compare Source
Fixes
--or-v4.5.37Compare Source
Features
ArgMatches::try_clear_id()v4.5.36Compare Source
Fixes
v4.5.35Compare Source
Fixes
help_headingv4.5.34Compare Source
Fixes
flatten_help(true)and subcommands without argumentsv4.5.33Compare Source
Fixes
v4.5.32Compare Source
Features
Error::removeDocumentation
humantimetojiffInternal
pulldown-cmarkv4.5.31Compare Source
Features
ValueParserFactoryforSaturating<T>v4.5.30Compare Source
Fixes
num_args(0..=1)to be used withSetTruetakes_valuesassertionsv4.5.29Compare Source
Fixes
ArgMatches::args_presentso not-present flags are considered not-present (matching the documentation)v4.5.28Compare Source
Features
unstable-markdownv4.5.27Compare Source
Documentation
v4.5.26Compare Source
Fixes
suggestionsfeaturev4.5.25Compare Source
Fixes
v4.5.24Compare Source
Fixes
ignore_errors(true)and when a suggestion is provided for an unknown argumentv4.5.23Compare Source
Fixes
allow_negative_numbers, allowEagainv4.5.22Compare Source
Fixes
v4.5.21Compare Source
Fixes
ignore_errors(true)v4.5.20Compare Source
Features
CommandExtv4.5.19Compare Source
Internal
v4.5.18Compare Source
Features
Arg::get_display_orderandCommand::get_display_orderv4.5.17Compare Source
Fixes
v4.5.16Compare Source
Fixes
derivefeature is missingv4.5.15Compare Source
Compatiblity
Arg::removechanged return typesFixes
Arg::removereturn the removed itemv4.5.14Compare Source
Features
Arg::addfor attaching arbitrary state, like completion hints, toArgwithoutArgknowing about itv4.5.13Compare Source
Fixes
#[flatten]ing an optional#[group(skip)]v4.5.12Compare Source
v4.5.11Compare Source
v4.5.10Compare Source
v4.5.9Compare Source
Fixes
v4.5.8Compare Source
Fixes
v4.5.7Compare Source
Fixes
num_argsv4.5.6Compare Source
v4.5.5Compare Source
Features
default_values_if,default_values_ifsv4.5.4Compare Source
Fixes
v4.5.3Compare Source
Fixes
v4.5.2Compare Source
Fixes
ArgMatches::args_presentso not-present flags are considered not-present (matching the documentation)v4.5.1Compare Source
Internal
v4.5.0Compare Source
Compatibility
v4.4.18Compare Source
Fixes
usagefeature, ensure the list of required arguments is uniquev4.4.17Compare Source
Fixes
panic!when mixingargs_conflicts_with_subcommandswithArgGroup(which is implicit withderive) introduced in 4.4.15v4.4.16Compare Source
Fixes
v4.4.15Compare Source
Fixes
args_conflicts_with_subcommandsargs_conflicts_with_subcommandswhen using subcommand short and long flagsv4.4.14Compare Source
Documentation
findcookbook entry to allow repeats of flags/optionsFeatures
num_args(0)on options which allows making them emulate being a flag for position-tracking flagsv4.4.13Compare Source
Documentation
v4.4.12Compare Source
Performance
TypedValueParserfor possible values if neededv4.4.11Compare Source
Features
Command::mut_groupv4.4.10Compare Source
Documentation
v4.4.9Compare Source
Fixes
Command::aboutunder flattened headingshidewhen flattening subcommandsv4.4.8Compare Source
Features
Command::flatten_helpto allowgit stash -hlike help for subcommandsv4.4.7Compare Source
Performance
v4.4.6Compare Source
Internal
anstreamv4.4.5Compare Source
Fixes
nameorlong_flag, allow ambiguous-looking matches that unambiguously map back to the same commandlong_flag, don't panicv4.4.4Compare Source
Internal
terminal_sizeto 0.3v4.4.3Compare Source
Documentation
v4.4.2Compare Source
Performance
once_celldependencyv4.4.1Compare Source
Fixes
usagefeature, ensure the list of required arguments is uniquev4.4.0Compare Source
compatibility
v4.3.24Compare Source
Fixes
--helpwith custom templatesv4.3.23Compare Source
Fixes
UnknownArgumentValueParserto not error on flag's absencev4.3.22Compare Source
Features
UnknownArgumentValueParserfor injecting errors for improving the experience with errorsv4.3.21Compare Source
Features
TryMapValueParserso the type can be namedv4.3.20Compare Source
Features
Command::mut_argsfor modifying all arguments en massev4.3.19Compare Source
Fixes
value_terminatoreven in the presence of later multiple-value positional argumentsv4.3.18Compare Source
Fixes
--in fewer places where it won't workv4.3.17Compare Source
Fixes
PossibleValuedescriptions in--helpv4.3.16Compare Source
Fixes
v4.3.15Compare Source
Features
anstyleDocumentation
v4.3.14Compare Source
Features
ArgAction::HelpShortandArgAction::HelpLongfor explicitly specifying which style of help to displayFixes
[OPTIONS]in usage if a help or versionArgActionis usedv4.3.13Compare Source
v4.3.12Compare Source
Fixes
v4.3.11Compare Source
Features
num::Wrapping,Box, orArcBox<str>,Box<OsStr>, andBox<Path>v4.3.10Compare Source
Performance
v4.3.9Compare Source
Fixes
Command::ignore_errorsno longer masks help/versionv4.3.8Compare Source
Fixes
infer_long_arg, rather than arbitrarily picking one, matching the documentation and subcommand's behaviorv4.3.7Compare Source
Documentation
v4.3.6Compare Source
Documentation
cliov4.3.5Compare Source
ColorChoice::possible_valuesis added to simplify things for builder usersFixes
ColorChoice::to_possible_valueno longer includes descriptions, encouraging shorter help where possiblev4.3.4Compare Source
Features
Error::exit_codev4.3.3Compare Source
Features
Command::deferfor delayed initialization of subcommands to reduce startup times of large applications like denov4.3.2Compare Source
Fixes
--helpwith custom templatesv4.3.1Compare Source
Fixes
value_terminatoreven in the presence of later multiple-value positional argumentsv4.3.0Compare Source
Fixes
lastassertionvalue_terminatorhas higher precedence thanallow_hyphen_values--helpv4.2.7Compare Source
Fixes
ArgMatchesv4.2.6Compare Source
Features
impl Eq<std::any::TypeId> for clap_builder::util::AnyValueIdv4.2.5Compare Source
Fixes
v4.2.4Compare Source
Documentation
Command::stylev4.2.3Compare Source
Features
Command::stylesfor theming help/errors (behindunstable-styles)v4.2.2Compare Source
Internal
v4.2.1Compare Source
Fixes
v4.2.0Compare Source
Compatibility
unstable-replacefeature (open to discussion at #2836)unstable-groupedfeatureFeatures
StyledStrto accept text styled with ANSI escape codesCLICOLOR,CLICOLOR_FORCEFixes
v4.1.14Compare Source
Features
#[group]raw attribute supportPerformance
clap_builderwas pulled out ofclapso it could build in parallel toclap_deriveos_str_bytesdependency was removed for faster builds and smaller binariesv4.1.13Compare Source
Performance
Commandv4.1.12Compare Source
Internal
synv2Performance
proc-macro-errordependencyv4.1.11Compare Source
Internal
bitflagsv4.1.10Compare Source
Fixes
v4.1.9Compare Source
Fixes
get_count/get_flagv4.1.8Compare Source
Fixes
denylints on the users behalfv4.1.7Compare Source
Fixes
v4.1.6Compare Source
Fixes
--helpjust because hidden possible values include a descriptionv4.1.5Compare Source
Fixes
--helpjust because a hidden arg has a possible value with a descriptionv4.1.4Compare Source
Fixes
disable_colored_helpwhen usingarg_required_else_helpPerformance
arg!macrov4.1.3Compare Source
Fixes
subcommands, rather thansubcommandv4.1.2Compare Source
Fixes
get_flag, rather thanget_one::<bool>v4.1.1Compare Source
Features
#[group]raw attribute supportPerformance
clap_builderwas pulled out ofclapso it could build in parallel toclap_deriveos_str_bytesdependency was removed for faster builds and smaller binariesv4.1.0Compare Source
Compatibility
MSRV changed to 1.64.0
For apps with custom
--helpand--versionflags:--helpand--versionchangedWhen apps have errors imitating clap's error style:
Features
ArgMatches::get_occurrencessupport for argument values to be grouped by their occurrenceFixes
upgrade_fromwhen arguments / subcommands are explicitly marked as required--helpand--version(also helps with overflow)v4.0.32Compare Source
Fixes
required(true), consider args that conflict with its groupv4.0.31Compare Source
Performance
v4.0.30Compare Source
Fixes
args_conflicts_with_subcommandv4.0.29Compare Source
v4.0.28Compare Source
Fixes
v4.0.27Compare Source
Features
Arg::value_parseracceptVec<impl Into<PossibleValue>>DisplayandFromStrforColorChoiceFixes
attytois-terminalv4.0.26Compare Source
Fixes
ContextKind::as_strv4.0.25Compare Source
Features
v4.0.24Compare Source
Fixes
v4.0.23Compare Source
Fixes
helpsubcommandv4.0.22Compare Source
Fixes
v4.0.21Compare Source
Features
long_aboutandlong_helpattributes, 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.20Compare Source
Fixes
v4.0.19Compare Source
Features
ColorChoicenow implementsValueEnumv4.0.18Compare Source
Fixes
#[command(skip)]to also work with enum variants with a valuev4.0.17Compare Source
Fixes
Arg::last(true)withArg::value_hint(ValueHint::CommandWithArguments)v4.0.16Compare Source
Fixes
Arg::exclusive(true)should not be exclusive with the argument's ownArgGroupv4.0.15Compare Source
Fixes
--when it doesn't helpv4.0.14Compare Source
Fixes
ArgGroupinArgMatcheswhen explicitly specified, fixing derives handling of option-flattened fields (#4375)v4.0.13Compare Source
Features
()for fields to mean "don't read" (#4371)v4.0.12Compare Source
Features
TypedValueParser::try_mapfor when adapting an existingTypedValueParsercan failError::new,Error::with_cmd, andError::insertv4.0.11Compare Source
Fixes
v4.0.10Compare Source
Features
#[arg(flatten)]onOptiontypes (#4211, #4350)v4.0.9Compare Source
Fixes
#[command(subcommand)]like in clap v3v4.0.8Compare Source
Fixes
HelpandVersionactionsv4.0.7Compare Source
Features
Fixes
#[group(skip)]onParserderivev4.0.6Compare Source
Features
#[group(skip)](#4279, #4301)v4.0.5Compare Source
v4.0.4Compare Source
Fixes
v4.0.3Compare Source
Fixes
required(true), consider args that conflict with its groupv4.0.2Compare Source
v4.0.1Compare Source
Features
ColorChoicenow implementsValueEnumv4.0.0Compare 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_argswhich accepts bothsingle values and ranges of values.
num_argscontrols how many raw argumentson 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
--helpoutput to make sure it ismeeting that goal.
In doing this evaluation, we wanted to keep in mind:
Before:
After:
--versionis available for showing the same thing (if the program has a version set)In talking to users, we found some that liked clap's
man-like experience.When deviating from this, we are making the assumption that those are more
power users and that the majority of users wouldn't look as favorably on being
consistent with
man.See Issue 4132 for more background.
More Dynamicism
Clap's API has focused on
&strfor performance but this can makedealing with owned data difficult, like
#[arg(default_value_t)]generating aString from the default value.
Additionally, to avoid
ArgMatchesfrom borrowing (and for some features wedecided to forgo), clap took the
&strargument IDs and hashed them. Thisprevented 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, orBox<str>for dynamic behavior with small binary size.As an extension of that work, you can now call
ArgMatches::idsto iterateover the arguments and groups that were found when parsing. The newtype
Idwas 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:
ArgActionValueParserAPIPathBuf(allowing invalid UTF-8)AppSettingsandArgSettingsenums with getters/settersMigrating
Steps:
-hand--helpoutput at a minimum (recommendation: trycmd for snapshot testing)arg.action(ArgAction::...)on each argument (StoreValuefor options andIncOccurrencesfor flags)cargo check --features clap/deprecatedand resolve all deprecation warningsdefault-features = false, runcargo add clap -F help,usage,error-contextcargo add clap -F wrap_helpunless you want to hard code line wrapsExample test (derive):
Example test (builder):
Note: the idiomatic / recommended way of specifying different types of args in the Builder API has changed:
Before
After:
In particular,
num_args(the replacement fortakes_value) will default appropriatelyfrom the
ArgActionand generally only needs to be set explicitly for theother
num_argsuse cases.Breaking Changes
Subtle changes (i.e. compiler won't catch):
arg!now sets one of (#3795):ArgAction::SetTrue, requiringArgMatches::get_flaginstead ofArgMatches::is_presentArgAction::Count, requiringArgMatches::get_countinstead ofArgMatches::occurrences_ofArgAction::Set, requiringArgMatches::get_oneinstead ofArgMatches::value_ofArgAction::Append, requiringArgMatches::get_manyinstead ofArgMatches::values_ofArgAction::Set,ArgAction::SetTrue, andArg::Action::SetFalsenowconflict by default to be like
ArgAction::StoreValueandArgAction::IncOccurrences, requiringcmd.args_override_self(true)to override instead (#4261)Args default action isArgAction::Set, rather thanArgAction::IncOccurrenceto reduce confusing magic through consistency (#2687, #4032, see also #3977)mut_argcan no longer be used to customize help and version arguments, instead disable them (Command::disable_help_flag,Command::disable_version_flag) and provide your own (#4056)Command,Arg,ArgGroup, andPossibleValue, assuming'static.stringfeature flag will enable support forStrings (#1041, #2150, #4223)arg!(--flag <value>)is now optional, instead of required. Add.required(true)at the end to restore the original behavior (#4206)help,usageanderror-context, requiring adding them back in ifdefault-features = false(#4236)""argument for external subcommands to make it easier to distinguish them from built-in commands (#3263)Arg::allow_hyphen_values, to be consistent withCommand::allow_hyphen_values(#4187)Arg::value_terminatormust be its own argument on the CLI rather than being in a delimited list (#4025)wrap_helpfeature flag, either enable it or hard code your wraps (#4258)DeriveDisplayOrderthe default and removed the setting. To sort help, setnext_display_order(None)(#2808)Command::next_display_orderinstead ofDeriveDisplayOrderand using its own initial display order value (#2808)Command::help_template(#4132)Command::help_template,Arg::help_heading, andCommand::subcommand_help_heading(#4132)COMMANDfor the value name. To get the old behavior, seeCommand::subcommand_help_headingandArg::subcommand_value_name(#4132, #4155)Command::help_template. (#4132, #4160)--helpand--versionlike anyArgAction::SetTrueflag ([#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.
This PR was generated by Mend Renovate. View the repository job log.