Commit graph

48 commits

Author SHA1 Message Date
Ed Page
f25fe5b3e0 chore: Bump MSRV to 1.64.0 2023-01-09 12:29:41 -06:00
Ed Page
abcee38466 fix(derive): Improve skip method error
Really this is about consolidating the skip checks but it also provideda
chance to improve the error.
2022-09-06 10:48:54 -05:00
Ed Page
ade931be57 fix(derive): Be less prescriptive
With how flexible clap's API is, it can be hard to determine what is
reasonable to use with its API, so let's just stop.
2022-09-06 07:56:08 -05:00
Ed Page
b29f3ff22f refactor(derive): Delay error handling 2022-09-06 07:56:08 -05:00
Ed Page
f9ad2c5f09 fix(derive): Guard against invalid attributes
We had some guards but this generalizes them and puts them on every
attribute.
2022-09-02 19:26:03 -05:00
Ed Page
2609b970a4 refactor(test): Update UI tests to new attributes 2022-09-02 15:23:04 -05:00
Ed Page
dbdd449dc3 refactor(derive): Further generalize kind errors 2022-09-02 14:03:34 -05:00
Ed Page
97ce0c44f7 refactor(derive): Generalize Kind based error checks 2022-09-02 14:03:34 -05:00
Ed Page
edce5c2119 fix(derive): Improve Kind conflict errors
This makes it better scale for the future
2022-09-02 10:48:38 -05:00
Ed Page
4e6733fbe5 fix(derive): Remove error case for default_value 2022-08-26 13:59:18 -05:00
Miguel Fernandez
42cb87b4b6 fix: Amend error message when deriving enums
Clarify that only unit variants are fully supported, and that
non-unit variants must be skipped.
2022-08-26 11:08:39 +02:00
Ed Page
85f541d789 fix: Switch to owned types
Impact:
- Binary size: 556.6 KiB to 578.4 KiB
- build time: 6.4950 us (7% slower)
- parse time: 7.7256 us
- parse sc time: 8.1580 us (5% faster)

Fixes #1041
Fixes #2150
2022-08-22 14:55:55 -05:00
Ed Page
3390adf0d3 chore: Bump MSRV to 1.60.0
While at it, this cleans up all of the features.  For some reason, I
couldn't do `dep:clap_derive` though.
2022-08-10 21:32:06 -05:00
Emerson Ford
04e0ed7474 feat(clap_derive): Add default_values_t and default_values_os_t 2022-07-25 10:14:04 -07:00
Ed Page
6ecb7310a8 fix(derive)!: Remove value_parser/action defaulted attributes 2022-07-22 20:07:47 -05:00
Ed Page
7068586246 fix(derive)!: Remove deprecated parse attribute 2022-07-22 12:14:29 -05:00
Ed Page
7307f22c73 fix(derive): Remove error check for old raw attributes 2022-07-22 11:41:00 -05:00
Ed Page
01a3ea425f fix!: Remove unstable-v4 feature gate 2022-07-22 11:34:06 -05:00
Ed Page
1281e78dc0 test: Limp along 2022-07-21 17:08:35 -05:00
Ed Page
3c4e684c8b test: Verify auto-traits for core types
By checking these types, we'll get some other types for free, like
`Command` verifying `Arg`.

This was inspired by #3876
2022-06-27 20:50:29 -05:00
Stiopa Koltsov
464ef3920b refactor: Put once_cell reexport into __macro_refs
When upgrading our company projects from clap 3.1 to clap 3.2 I had
to fix several references to `clap::lazy_init`. People are not
supposed to do that, but that's hard to enforce.

Hope placing `once_cell` reexport into `__macro_refs` prevent at
least some of the such issues in the future.
2022-06-26 04:13:03 +01:00
Ed Page
7515bfeb51 fix: Allow people to opt-in to deprecations
This adds a new `Cargo.toml` feature named `deprecated` that opts
controls whether deprecation warnings show up.  This is starting off as
non-default though that may change (see below).

Benefits
- Allows a staged rollout so a smaller subset of users see new
  deprecations and can report their experience with them before everyone
  sees them.  For example, this reduces the number of people who have to
  deal with #3822.
- This allows people to defer responding to each new batch of
  deprecations and instead do it at once.  This means we should
  reconsider #3616.

The one risk is people who don't follow blog posts and guides having a
harder time upgrading to the next breaking release without the warnings
on by default.  For these users, we reserve the right to make the
`deprecated` feature `default`.  This is most likely to happen in a
minor release that is released in conjunction with the next major
release (e.g. when releasing 4.0.0, we release a 3.3.0 that enables
deprecations by default).  By using a feature, users can still disable
this if they want.

Thanks @joshtriplett for the idea
2022-06-14 10:50:05 -05:00
Ed Page
0a529c14cc fix(derive): Switch default actions/parsers for unstable-v4 2022-06-13 18:59:58 -05:00
Ed Page
9910b1477b fix(derive): Find a better target for validator deprecation warnings
Putting it on the doc comment is weird.  We are now putting it on the
field which is a slight improvement.  This better conveys "this is
auto-generated".

No test was added because the use case that I know of for exposing this
is short lived.
2022-06-13 16:14:05 -05:00
Ed Page
ca2846615c docs(parser): Encourage people to read the whole deprecation message 2022-06-10 19:41:50 -05:00
Ed Page
9caec5a52d fix(parser): Deprecate ArgMatches::is_present 2022-06-10 14:21:25 -05:00
SabrinaJewson
560f0c076a
fix: Appease CI 2022-06-08 20:45:25 +01:00
SabrinaJewson
6e49bf7419
refactor: Make AnyValueParser private 2022-06-08 20:36:55 +01:00
Ed Page
9e38353442 fix(derive): Clarify ArgEnum as ValueEnum
We aren't enumerating arguments but values for an argument, so the name
should reflect that.

This will be important as part of #1807 when we have more specific
attribute names.
2022-06-08 11:14:09 -05:00
Ed Page
11d93141dd test(derive): Update snapshots 2022-06-08 09:56:57 -05:00
Ed Page
002204a122 test(derive): Update ui tests 2022-06-04 13:24:46 -05:00
Ed Page
34368419c2 refactor(bench): Pull out benchmarks into own crate
This is mostly about avoiding criterion's build times when just
developing clap itself.

I'm assuming the derive test changed because criterion's clap v2 isn't
in the dependency tree anymore.
2022-06-03 13:51:26 -05:00
Ed Page
552e6feb3f fix(derive): Adjust precedence for flag/occurrence logic 2022-06-02 16:56:12 -05:00
Ed Page
cccc88bcc2 fix(derive): Fix typo in error messages 2022-06-02 16:46:50 -05:00
Ed Page
773ba94c4e refactor(derive): Merge handling of bool/from_flag
This will make it easier to divide off parser logic for adding in
actions.

This does mean we can't provide error reporting on bad values with
`bool` but
- We should have also been doing that for `from_flag`
- We'll be dropping this soon in clap4 anyways
2022-06-02 13:01:59 -05:00
Ed Page
dfc55cd6e3 test(derive): Update ui test to be correct otherwise 2022-06-02 11:59:09 -05:00
Ed Page
408ca3c5d7 test(derive): Update for deprecations 2022-05-25 13:13:22 -05:00
Ed Page
b52c7f115e feat(derive): Allow users to opt-in to ValueParser
For clap 3, its opt-in as a precaution against breaking
compatibility in some weird cases.

This does require the types to implement `Clone`.

Fixes #3734
Fixes #3496
Fixes #3589
2022-05-20 15:38:44 -05:00
Ed Page
e0e7383300 test: Re-enable ui tests
`derive_ui.rs` did not have a marker for needing to be updated on MSRV
changes, so it got missed.
2022-05-20 14:10:32 -05:00
Ed Page
17c99d2878 test(derive): Unsure why this is failing 2022-05-12 06:23:38 -05:00
Liu Dingming
1b63fbd6df feat(derive): Start unstable-v4 feature flag
This is split out of #3661 as several changes I'm working on need it.
2022-05-06 14:56:55 -05:00
shir0kamii
fb4755d1c3 feat(derive): Don't abort when non-unit variant is skipped 2022-03-31 18:49:21 +02:00
shir0kamii
ee3d12ec56 fix(derive): Abort on non-unit variant 2022-03-30 03:49:14 +02:00
Ed Page
7aa45667f5
Merge pull request #3472 from epage/cmd
fix: Rename App to Command
2022-02-15 07:55:36 -06:00
Maarten de Vries
bd68653248 test: Add UI test for unsupported parsers 2022-02-15 12:00:25 +01:00
Ed Page
c4144d7d6c docs: Update App references to Command 2022-02-14 15:33:49 -06:00
Rob Donnelly
a19bca8a10 docs(error): Update link to explicit bool parser example 2022-01-31 21:58:54 -08:00
Ed Page
b190a6a817 test: Consolidate clap tests
This reduces the need for us to have `clap` as a dependency in
`clap_derive`, preparing the way to fix #15.
2021-11-30 10:07:08 -06:00