Ed Page
889ca7a537
chore: Bump versions for 4.1
2023-01-13 09:24:37 -06:00
Thayne McCombs
65f9e0d747
refactor(derive): Clean up unnecessary noop parsing
...
My guess is this was left over from switching to using the type based
API. The generated code for extracting values from `ArgMatches` had some
code that didn't actually do anything, like mapping over the identity
function, and wrapping a value in an `Ok` only to immediately use "?" on
it.
2023-01-11 01:38:36 -07:00
Ed Page
e576c65dee
style: Make clippy happy
2023-01-10 09:08:12 -06:00
Ed Page
084991f70a
Merge pull request #4600 from tmccombs/groups-derive
...
Add support for deriving grouped options for Vec<Vec<T>>
2023-01-10 08:43:36 -06:00
Ed Page
50f033e6bc
fix(derive): Allow users to override arg_required_else_help on sub-sub commands
2023-01-09 21:08:56 -06:00
Ed Page
af71ada3f4
fix(derive): Allow update_from
when explicit requireds used
...
Fixes #4617
2023-01-09 20:52:46 -06:00
Ed Page
fa02111092
chore: Switch to workspace inheritance
2023-01-09 12:35:54 -06:00
Ed Page
f25fe5b3e0
chore: Bump MSRV to 1.64.0
2023-01-09 12:29:41 -06:00
Thayne McCombs
73df3d1a1e
chore: Put Vec<Vec<_>> behave for derive behind unstable-v5 flag
2023-01-08 00:28:01 -07:00
Thayne McCombs
eaa9273f91
feat: Add support for deriving grouped options for Vec<Vec<T>>
...
Relates-To: #2924
2023-01-07 23:36:45 -07:00
Tom Forbes
1b32087418
Fix typo in clap-derive error message
...
I assume "litersl" should be "literals"?
2023-01-02 01:39:14 +00:00
Ed Page
bc457b179f
chore: Release
2022-11-07 10:00:35 -06:00
Ed Page
c37ab6c205
fix(derive): Allow 'long_help' to force populating from doc comment
...
Fixes #4441
2022-11-07 09:41:52 -06:00
Ed Page
c1a9da9124
refactor(derive): Decouple extracting and formatting of doc comments
2022-11-07 09:17:04 -06:00
Ed Page
214f6b8966
refactor(derive): Clarify bool arg
2022-11-07 08:31:37 -06:00
Ed Page
73be1fef99
refactor(derive): Remove dead code
2022-11-07 08:08:06 -06:00
Ed Page
5ee9e0fe76
refactor(derive): Decouple doc comment parsing from methods
2022-11-07 08:06:10 -06:00
Ed Page
6ace0410c1
refactor(derive): Clarify leading-space removal
2022-11-07 07:49:44 -06:00
Ed Page
d1db3d2f0e
refactor(derive): Clarify empty doc needs
2022-11-07 07:48:16 -06:00
Ed Page
b4b94af0f8
chore: Release
2022-11-07 06:24:02 -06:00
Ed Page
79225d3a2d
fix(derive): Allow defaulted value parser for '()' fields
...
Inspired by #4458
This is a compatible change because it turns a compiler error into a
working case.
2022-11-07 06:07:51 -06:00
Ed Page
7e2a1b5d94
chore: Release
2022-10-20 16:58:59 -05:00
Ed Page
91daec67ca
fix(derive): Allow skipping enum variants with a value
...
Fixes #4411
2022-10-20 16:44:51 -05:00
Ed Page
e5a7a65153
chore: Release
2022-10-11 10:43:39 -05:00
Ed Page
b26c01aa0e
feat(derive): Allow type-less fields
...
When overriding other fields, help or version flag, globals, etc, a user
might not care about the value, so let's ignore the lookup.
Been talking about this for a while but Issue #4367 moved this forward
because there wasn't a good way to handle this without changing
behavior.
2022-10-11 10:31:42 -05:00
Ed Page
af1234a0c2
chore: Release
2022-10-05 16:51:33 -05:00
Ed Page
78676f5043
fix(derive): Make mismatched behavior more obvious
...
If the inner type never implemented `group_id()`, then it won't work and
people will be confused. This at least gives people an idea of whats
going wrong.
This is most likely to be a problem until #3165 is fully implemented but
hand-implementations can still run into this. Probably should have made
the groups another trait to catch this in type system but too late.
2022-10-05 16:25:14 -05:00
Ed Page
06d2049931
feat(derive): Support 'Option' when flattening
2022-10-05 16:21:00 -05:00
Ed Page
33db640dd5
refactor(derive): Make flatten's update prepped for Option
2022-10-05 16:12:12 -05:00
Ed Page
f121a8bdf6
fix(derive): Better subcommand type errors for Vec
2022-10-05 16:03:48 -05:00
Ed Page
4f17f998cb
fix(derive): Better flatten type errors
2022-10-05 15:59:45 -05:00
Ed Page
1d533bb31f
chore: Release
2022-10-03 16:20:14 -05:00
Ed Page
7ceb08ac70
fix(derive): Apply doc comments for #[command(subcommand)]
...
This was broken in 8a5a9ba931
. I had
missed this case for parsing doc comments.
2022-10-03 16:04:38 -05:00
Ed Page
261fb792a4
chore: Release
2022-10-01 13:54:19 -05:00
Ed Page
05bf0504f0
chore: Remove outdated replacement
2022-10-01 13:54:08 -05:00
Ed Page
03085e9dd1
docs(derive) Fix README links
...
Fixes #4314
2022-09-30 19:56:05 -05:00
Ed Page
0bea4f252b
chore: Release
2022-09-30 14:08:59 -05:00
Ed Page
5f145a23e9
fix(derive): Support 'group' attribute with Parser
2022-09-30 13:44:10 -05:00
Ed Page
42122787d7
feat(derive): Report the group id
...
This will be needed when we support flattening for #3165
2022-09-30 12:24:21 -05:00
Ed Page
50ad905b6a
feat(derive): Implicitly populate groups from some structs
...
This implements the basics for #3165 , just missing
- `flatten` support (waiting on improved group support)
- `group` attributes
2022-09-30 11:42:06 -05:00
Ed Page
470140f41e
chore: Release
2022-09-30 09:31:51 -05:00
Ed Page
2498147138
feat(derive): Allow skipping the implicit ArgGroup
...
This was prioritized to allow users to workaround problems when the
implicit `ArgGroup` is getting in the way.
Fixes #4279
2022-09-30 09:15:38 -05:00
Ed Page
6ca0569baa
fix(derive): Pipe group attribute through
...
Still doesn't support any attributes within it yet.
2022-09-30 08:56:35 -05:00
Ed Page
f6602c573c
chore: Release
2022-09-28 14:51:22 -05:00
Ed Page
24be631f86
fix(derive): Ensure clap/structopt attributes still work
...
The problem with updating all code to use non-deprecated APIs, there
aren't tests for the old way anymore.
Fixes #4274
2022-09-28 14:29:39 -05:00
Ed Page
79ba02daa5
fix(derive): Quote the attribute in the error
2022-09-28 14:27:08 -05:00
Ed Page
3a74d82376
chore: Release
2022-09-28 12:00:48 -05:00
Ed Page
a82029c707
chore: Release
2022-09-20 16:30:29 -05:00
Ed Page
fe43f0c945
Revert "fix: Remove once_cell dependency from derive"
...
This reverts commit 429143af42
.
2022-09-16 16:19:03 -05:00
Ed Page
7ccaebb65d
refactor(parser): Switch from Box<str>
to String
...
This is a more familiar type for people and it didn't cost us anything
(in fact it undid the code size change in the last commit).
2022-09-16 16:14:32 -05:00
Ed Page
1e13109a26
refactor(parser): Track subcommands with Box<str>
...
The overall hope is to allow a `&'static str`-only version of clap, so
we need to move off of `Str` where dynamic strings are required. We
need it here for subcommands due to external subcommands.
This had minimal impact on code size (567.2 to 567.5 KiB)
2022-09-16 16:14:32 -05:00
Ed Page
14c6ce0e83
fix(derive): Remove next_help_heading isolation
...
Originally, I saw the ideal as the parent command being isolated from
`#[clap(flatte)]` especially after all of the doc comment
leakage issues. We scaled that back to just `next_help_heading` because
of the issues with settling on a policy and maintenance to cover
everything. When doing `next_display_order`, we decided it would mess
things up too much to isolate it.
With #1807 , we instead have been moving towards setting
`#[command(next_help_heading)]` anywhere, we just need to finish working
out how it should work.
2022-09-16 15:31:49 -05:00
Ed Page
417f1a9813
fix(derive): Read CARGO_PKG_NAME at runtime
...
This was broken in #4168
2022-09-16 14:31:58 -05:00
Ed Page
d3bf5450ff
feat(derive): Reserve the T group name
...
Since the `name` is changed to be the package name, we can't use it as
(1) its not as predictable and (2) it can lead to conflicts if a
`Parser` is flattened into a `Parser`
2022-09-13 07:44:36 -05:00
Ed Page
3bfa9d5ff0
feat(derive): Reserve 'group' attribute
2022-09-13 07:06:06 -05:00
Ed Page
17f49df4e2
revert(derive): Bald action/value_parser are deprecated, its good enough
...
When I removed these in v5, we didn't have a deprecation approach for
the derive and I didn't want to forget. Now we do have a deprecation
approach and that is the reminder, so we don't need to carry around v5
changes.
2022-09-07 19:34:50 -05:00
Ed Page
ede8fd6dbd
style(derive): Clean up to make explicit methods easier
2022-09-06 12:54:50 -05:00
Ed Page
9c85839705
refactor(derive): Simplify processing of Subcommand
2022-09-06 12:54:50 -05:00
Ed Page
51dc3c63d6
refactor(derive): Treat subcommands like other Kinds
2022-09-06 12:54:50 -05:00
Ed Page
222003abe1
fix(derive): Disallow general attributes with from_global
2022-09-06 12:54:50 -05:00
Ed Page
a71b2eb8b8
refactor(derive): Shift responsibility for long help
2022-09-06 12:54:47 -05: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
8a5a9ba931
perf(derive): Only parse doc comments when needed for field/variant
2022-09-06 10:43:16 -05:00
Ed Page
9eb72ea5b6
fix(derive): Disallow attributes on top-level ValuEnum
2022-09-06 10:40:12 -05:00
Ed Page
1d973bd1c1
perf(derive): Don't parse ValueEnum's doc comment to ignore it
2022-09-06 10:36:22 -05:00
Ed Page
eece51fe04
refactor(derive): Give more control to the derive
2022-09-06 10:35:19 -05:00
Ed Page
71b9209a34
refactor(derive): Simplify Kind initialization
2022-09-06 07:56:08 -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
f9e1ba2c1e
fix(derive): Improve the default span
2022-09-06 07:56:07 -05:00
Ed Page
6648cf6009
refactor(derive): Remove unused Type for values
...
They have no type
2022-09-06 07:55:23 -05:00
Ed Page
f571821670
refactor(derive): Decouple attr and kind processing
2022-09-03 20:58:26 -05:00
Ed Page
9abcae2ac3
refactor(derive): Separate parsing from pushing of attrs
2022-09-03 20:56:33 -05:00
Ed Page
a7ed5d012d
fix(derive): Deprecate using name
for Args
...
The builder function was deprecated in v3 and removed in v4 but the
derive masked that, so we're still adapting things but now with a path
towards removal.
2022-09-02 19:57:37 -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
707f47f435
fix(derive): Deprecate 'clap' attribute
2022-09-02 15:39:24 -05:00
Ed Page
2609b970a4
refactor(test): Update UI tests to new attributes
2022-09-02 15:23:04 -05:00
Ed Page
e0f2f6fbae
fix(derive): Builder-specialized attributes
2022-09-02 14:06:27 -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
59a4578898
refactor(derive): Track the item's Kind
2022-09-02 14:03:34 -05:00
Ed Page
0ae119fda9
fix(derive): Report deprecations for structopt attributes
...
This is more of a test bed for adding new attributes and deprecating
clap ones.
2022-09-02 14:03:31 -05:00
Ed Page
7b0c76de31
Revert "fix(derive): Remove structopt attribute support"
...
This reverts commit 521a012c28
.
2022-09-02 11:15:15 -05:00
Ed Page
7eaa226526
fix(derive): Provide deprecations for bald action/value_parser
...
These will be going away, so we should tell the user.
This is mostly a test bed for our new deprecation plumbing.
2022-09-02 11:14:31 -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
11ffcf9393
refactor(derive): Determine an Item's Kind first
...
This will allow the attribute processing to change based on the kind
2022-09-02 10:41:34 -05:00
Ed Page
c56277c084
refactor(derive): Make Sp copyable
2022-09-02 10:23:09 -05:00
Ed Page
6d44106e76
fix(derive): Remove helper for removed help_heading
2022-09-02 09:58:08 -05:00
Ed Page
5264a62181
perf(derive): Consolidate field/variant parsing
2022-09-01 13:54:43 -05:00
Ed Page
6e8b366107
perf(derive): Stop generating redundant code
2022-09-01 13:50:27 -05:00
Ed Page
a47462123c
refactor(derive): Only pass around what is needed
2022-09-01 13:21:57 -05:00
Ed Page
a86cb8a26c
refactor(derive): Rely on Self for enums
2022-09-01 12:14:55 -05:00
Ed Page
0b5f95e3a3
perf(derive): Further consolidate parsing of attrs
2022-09-01 12:04:10 -05:00
Ed Page
d8524b5ad1
refactor(derive): Clarify parse is really about attributes
2022-09-01 07:07:19 -05:00
Ed Page
d9844002e5
refactor(derive): Clarify we are dealing with API item
2022-08-31 21:19:26 -05:00
Ed Page
7242e22810
perf(derive): Reduce number of times attributes are parsed
2022-08-31 19:58:14 -05:00
Ed Page
78dc60bd37
refactor(derive): Be explicit in what is being parsed
2022-08-31 10:11:49 -05:00
Ed Page
36460aed08
fix: Deprecate _os variants
...
PR #4096 made them redundant
2022-08-29 12:42:30 -05:00
Ed Page
521a012c28
fix(derive): Remove structopt attribute support
2022-08-26 16:06:10 -05:00
Ed Page
c04fe2fa4b
refactor(derive): Allow carrying context with parsed attributes
2022-08-26 15:52:21 -05:00