Commit graph

1146 commits

Author SHA1 Message Date
Ed Page
a360fd8ac0 test(parser): Verify value terminator precedence 2023-05-19 11:04:48 -05:00
Ed Page
e1db168d69 fix(parser): Ensure terminated positionals are assigned correctly 2023-05-19 10:41:44 -05:00
Ed Page
1ee2e95e96 fix(builder): Allow value terminated multiple positional values 2023-05-19 10:39:05 -05:00
Ed Page
130b2ff997 test(parser): Show multiple positional multiple values behavior 2023-05-19 10:36:43 -05:00
Ed Page
c3fe7ff0a9 fix(help): Don't use next-line-help on long-help for subcommands
Subcommands don't switch their behavior on `--help`, so let's not switch
to next-line-help based on `--help`.

Fixes #4897
2023-05-12 10:41:05 +02:00
Ed Page
21d911db10 style: Make clippy happy 2023-05-19 09:10:20 -05:00
Ed Page
67cc5ea3a2 fix(assert): Clarify last assertion
An incremental improvement for #4911.
2023-05-17 16:33:36 -05:00
Yuri Astrakhan
d0302c5556 chore: Inline simple non-mixed format args 2023-05-04 15:58:04 -04:00
Ed Page
1351c56289 fix(help): Consistently calculate PV name length 2023-05-03 20:15:31 -05:00
Ed Page
3963d73e18 perf(help): Remove next-help possible values
Next-line help for possible values does not feel like its pulling its
weight.  If anything we should do next-line help for the entire
argument.

This dropped about 0.5 KiB but more importantly is prep for other
changes.
2023-05-03 20:09:36 -05:00
Yuri Astrakhan
797c23c415 chore: Inline format args using clippy fix
This command cleaned up all the format args,
making code significantly shorter and more readable.

```
cargo clippy --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2023-05-03 21:49:11 -04:00
Ed Page
950a495753 fix(help): Preserve block indent when wrapping 2023-04-19 11:55:53 -05:00
Ed Page
71344749e7 test(help): Show indented wrap behavior 2023-04-19 11:37:03 -05:00
Ed Page
feddd124b0 style: Move away from banned fns 2023-03-30 02:18:00 -05:00
Ed Page
56fe5e0ec0 fix!: Remove unstable-replace feature flag
This has been implemented for 3 years without much traction for
finishing it up.

The subcommand use case can be worked around by creating `Command`s that
just include the relevant logic, very similar to the default subcommand
examples in `git` / `git-derive`.

Using this for flags is covered by #4793.

Without `unstable-replace` being enabled, this still cut 5 KiB from
`cargo bloat --release --example git`.

Closes #2836
Closes #2011
2023-03-28 00:26:45 -05:00
Ed Page
fa60e723fc fix(error): Give more idea why we are suggesting an arg
One challenge with this is finding something that generally works.
Making this work perfectly for one setting will make it inconsistent
with other settings and take up more binary size / compile time.

So in the end, I felt like just mirroring rustc (with a bit more
brevity) seemed like a decent experiment.  This will be evaluated by the
feedback on release.

This is a small part of #4638
2023-03-27 20:45:27 -05:00
Ed Page
234d5f91d1 fix(error): Change from neutral 'note' to helpful 'tip'
This also has the advantage of aligning with `error:`

This is a small part of #4638
2023-03-27 20:45:11 -05:00
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
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
953e2dcd34 docs: Remove remaining references to clap attribute 2023-02-18 18:42:07 -06:00
Martin Fischer
8c92ef6c76
fix(help): Fix yet another --help long help edge case (#4712) 2023-02-15 11:33:35 -06:00
Martin Fischer
473cf175a2
fix(help): Fix --help help text in edge case (#4710)
We were accidentally showing long help just because a hidden argument had a description for a possible value.  This is most likely to be hit with the derive API as the value descriptions are automatically applied from documentation.
2023-02-15 10:25:19 -06:00
Martin
704d0e7a4f chore: Make format!() calls more readable 2023-01-29 19:14:47 +00:00
Cornelius Roemer
5dcc5c9509 fix: Add plural s in suggestions
Old: `note: subcommand 'test', 'temp' exist`
New: `note: subcommands 'test', 'temp' exist`
Fixes #4666
2023-01-23 22:16:50 +01:00
Ed Page
9d1de20787 docs: Prefer get_flag over get_one::<bool>
Inspired by #4654
2023-01-23 09:23:38 -06:00
Ed Page
162a556dba fix(error): Try to soften unexpected argument/value errors
Adding "found" might seem minor but I feel it has a slight softening on the message.  It also maintains scanability as it is at the end and short.

As this is a one-off message change and not a styling issue to be consistent with, I think this is safe to put in a patch release.
2023-01-13 21:29:49 -06:00
Ed Page
b4f111a978 feat: Stablize ArgMatches::get_occurrences
This let's you get an arguments values, grouped by the occurrence of the
argument.

Note: this does not stablize derive support.  That requires a blocking
change and can be enabled via `unstable-v5` flag.  See #4626 for an
exploration of how we can make this easier in the future.

Fixes #2924
2023-01-12 21:37:19 -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
af71ada3f4 fix(derive): Allow update_from when explicit requireds used
Fixes #4617
2023-01-09 20:52:46 -06:00
Ed Page
b9ae787d6b test(derive): Show update_from bug with explicit required 2023-01-09 20:52:45 -06:00
Ed Page
7b69dea24f test(derive): Unwrap, don't exit 2023-01-09 20:52:06 -06:00
Ed Page
f25fe5b3e0 chore: Bump MSRV to 1.64.0 2023-01-09 12:29:41 -06:00
Ed Page
d745c32f4f test(builder): Fix failing test 2023-01-09 11:59:20 -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
ccce3c3db5 test: Add test for opting out of Vec<Vec<T>> derive 2023-01-07 23:36:45 -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
Ed Page
762b06fba4 fix(error): Try to polish/clarify messages
In text communication you need to balance
- Scannability, putting the most important information upfront
- Brevity so people don't get lost in the message
- Softness to help ease people through a frustrating experience

I feel we weren't doing great on the first two points, so tried to
iterate on the messages to improve them.  I hope we aren't suffering too
much on the third point as a side effect.
2023-01-06 17:01:36 -06:00
Ed Page
68a7740fdc fix(error): Match rustc for giving more information 2023-01-03 13:22:35 -06:00
Ed Page
c2efb60a5f fix(error): Lowercase the start of error messages
This matches the rustc error style
2023-01-03 13:17:46 -06:00
Ed Page
e7d58b3daf
Merge pull request #4385 from epage/errors
fix(error): Be consistent with rustc diagnostic guidelines
2023-01-03 12:54:16 -06:00
Ed Page
36bc641648 fix(help): Remove extraneous text from built-ins
This is an intermediate solution for #4408.  As there were no agreeed
upon goals, I went with what I felt read well and that I saw commonly
used on non-clap commands.

- "information" isn't really a necessary word.
- I originally favored `Print this help` but realied that doesn't read
  correctly in completions.
- Besides being shorter, the reason for the flipped short/long hint is
  it gives people the context they need for scanning, emphasizing
  "summary" and "more".

Fixes #4409
2023-01-03 11:02:26 -06:00
Ed Page
85ecb3e895 fix(parser): Override required when parent group has conflict
Fixes #4569
2022-12-22 13:09:14 -06:00
Ed Page
d145b8b166 test(parser): Demonstrate required-overload bug 2022-12-22 13:08:02 -06:00
Ed Page
9242e1dd00
Merge pull request #4566 from hitenkoku/fix/4565
removed {bin} variable from help_template
2022-12-22 10:33:22 -06:00
DastInDark
c6058dee6e fix(help_template): Added cfg 2022-12-22 01:13:20 +09:00
DastInDark
a42204243a fix(help_template): Remove {bin} variable 2022-12-22 01:13:02 +09:00
Thayne McCombs
6abc2cfc3b feat: Add get/remove API for getting grouped values
Change it to be more consistent with get_one and get_many and related
functions.

Relates-To: #2924
2022-12-20 22:50:03 -07:00
Ed Page
453ac0bfb9 fix(parser): Be less confusing with args/subcommand conflicts
The new error message still isn't great but its better than the old one.

Reported at https://hachyderm.io/@eminence/109548978776785113
2022-12-20 20:27:58 -06:00