Commit graph

318 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
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
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
d745c32f4f test(builder): Fix failing test 2023-01-09 11:59:20 -06: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
Ed Page
2a374db639 test(parser): Show bad behavior 2022-12-20 20:23:49 -06:00
Ed Page
f632424e65 test(parser): Consolidate args_conflicts_with tests 2022-12-20 20:23:44 -06:00
Ed Page
e30e9823f2 test(parser): Verify value_source 2022-11-29 20:26:37 -06:00
Ed Page
623ccbc152 style: Make clippy happy 2022-11-24 08:05:21 -06:00
Ed Page
6b62c82fe2 feat(parser): Show available subcommands when one is missing
Similar to
- Listing all required arguments when one is missing
- Listing all possible values when no value is provided

This came up when discussing #3572
2022-11-15 10:18:24 -06:00
Ed Page
d21ee513fd test(parser): Verify subcommand required message 2022-11-15 10:12:05 -06:00
Ed Page
e9cbed34cd fix(parser): Don't panic on invalid UTF-8 values
Fixes #4473
2022-11-11 12:26:04 -06:00
Ed Page
45d26e0013 test(parser): Show UTF8 bug 2022-11-11 12:22:30 -06:00
Ed Page
ec03972023 test(assert): Verify empty positional assert exists
Wondered if we had this for #4467.  Figured we should actually test it.
2022-11-09 22:10:37 -06:00
Ed Page
9376a57d40 fix(help): Clarify that 'help' command accepts multiple
Making this plural can go either way as
- Clarify it is plural
- This is all really to simulate actually doing subcommands and you only
  do one at a time

For now, I lean towards clarifying it is plural

I also tweaked the message to be more consistent with how `--help` and
`-h` describe themselves.

Fixes #4342
2022-11-07 23:04:04 -06:00
Ed Page
dfe9e73880 fix(help): Update auto-next-line to use new padding
In clap v4, we changed the padding from 4 to 2 but we didn't update our
calculation for when to switch to next-line-help as it was a magic
number (we tried to catch all of these).

When updating the tests, we also missed that a test was being wrapped
too narrowly

This was found while discussing #3300
2022-11-07 10:36:51 -06:00
Ed Page
45dcf0ed22 fix(parser): Don't make Args exclusive with their ArgGroup
This is most obvious with the derive API as it creates `ArgGroup`s all
over the place now.

Fixes #4396
2022-10-17 19:02:39 -05:00
Ed Page
f1ffc63a79 fix(error): Be consistent with rustc diagnostic guidelines
From
https://rustc-dev-guide.rust-lang.org/diagnostics.html#suggestion-style-guide

> Suggestions should not be a question. In particular, language like
> "did you mean" should be avoided. Sometimes, it's unclear why a
> particular suggestion is being made. In these cases, it's better to be
> upfront about what the suggestion is.
>
> The message may contain further instruction such as "to do xyz, use"
> or "to do xyz, use abc".

Inspired by #2766
2022-10-13 14:01:49 -05:00
Ed Page
0f3c98a799 fix(error): Be consistent in puncutation 2022-10-13 13:56:58 -05:00
Ed Page
a4bcba6840 fix(error): Consistently indent suggestions 2022-10-13 12:10:13 -05:00