Commit graph

521 commits

Author SHA1 Message Date
Kurtis Nusbaum
5430df7a0f feat(derive): Support #[group] attributes
This adds the ability derive additional options for the group creation.

Fixes #4574
2023-03-25 03:25:38 -05:00
Ed Page
4e1a565b8a refactor: Split out clap_builder for faster derive builds
For now, we are still treating `clap` as the user facing API for both
builder and derive, making this an internal change as we don't expect
this to negatively impact builder build times all that much.  We can
re-evaluate at a later time and consider having distinct top-level
crates for builder and derive.

Looking at `--timings` on my machine
- `clap` only took 0.04s to build and it happened in
  parallel to `clap_builder` codegen
- this saved 1.7s for derive build times, with `clap_builder` building
  in parallel to `syn` and `clap_builder` and `clap_derive` finishing
  around the same time.

This was discussed some at https://rust-lang.zulipchat.com/#narrow/stream/220302-wg-cli/topic/clap.20build.20times.20and.20.60clap_derive.60.3A.20a.20crazy.20idea
2023-03-24 21:50:02 -05:00
Ed Page
7e7a45ac19 perf(derive): Reduce the amount of generated code
Its a small win, dropping the number of copies and reducing the
overhead from `quote` but enough of these could make a difference
2023-03-18 14:51:13 -05:00
Ed Page
79b44d0460 chore: Release 2023-03-18 09:17:44 -05:00
Ed Page
062622fe2d chore(derive): Update syn 2023-03-18 08:50:41 -05:00
Ed Page
e030426819 refactor(derive): Remove proc-macro-error dependency
Made things simpler that we were always aborting before.
2023-03-18 07:08:22 -05:00
Ed Page
e78bba0ec5 chore: Release 2023-03-16 10:42:06 -05:00
Ed Page
6c0600a031 chore: Fully specify dependencies 2023-03-16 06:07:08 -05:00
Ed Page
f931de694a chore: Release 2023-02-27 12:13:11 -06:00
Mingwei Samuel
fa76f6f78d fix: Remove strict linting from generated code
fix https://github.com/clap-rs/clap/issues/4733
2023-02-27 21:29:47 -08:00
Ed Page
5f247f5181 chore: Release 2023-02-27 07:55:14 -06:00
Roman Krasiuk
5bab68a16f fix: Allow clippy::almost_swapped 2023-02-27 19:42:44 +02:00
Roman Krasiuk
872135b64f fix: Allow clippy::almost_swapped 2023-02-27 19:35:01 +02:00
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