Commit graph

3055 commits

Author SHA1 Message Date
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
a72f962d35 docs(builder): Escape non-tags 2022-12-20 07:55:04 -06:00
Ed Page
ac48e2d5e4 docs: Make less brittle for rust versions 2022-12-20 07:54:30 -06:00
Ed Page
aa5420469e
Merge pull request #4555 from epage/reset
docs: Clarify role of Resettable
2022-12-14 21:04:29 -06:00
Ed Page
16c499c7b3 docs: Clarify role of StyledStr 2022-12-14 19:29:01 -06:00
Ed Page
1f3d5a321f docs: Clarify role of Resettable
Inspired by #4554
2022-12-14 19:21:08 -06:00
Dezhi Wu
577b7f24fa docs: Fix a typo 2022-12-14 15:47:15 +08:00
Ed Page
bf39b8d280 docs(ref): Move flatten/subcommand to be under command attr
Fixes #4505
2022-11-28 09:49:15 -06:00
Ed Page
20e02eb34e
Merge pull request #4509 from epage/possible
feat: Improve ValueParser experience
2022-11-24 10:06:52 -06:00
Ed Page
fb1d960fe2
Merge pull request #4249 from jcgruenhage/replace-atty
chore: replace atty with is-terminal
2022-11-24 09:48:37 -06:00
Ed Page
94aca92e44 feat: Create ValueParser from Vec<PossibleValue>
This dynamically generated list of possible values.  Inspired by #4504
2022-11-24 09:47:33 -06:00
Ed Page
3bccfced1a docs: Clarify PossibleValue is likely not needed
Fixes #4504
2022-11-24 09:47:33 -06:00
Ed Page
19981a2455 docs: Clarify ColorChoice impls ValueEnum 2022-11-24 09:47:33 -06:00
Ed Page
8d92f3e7a8 feat: Add Display/FromStr to ColorChoice
This matches up with `clap_complete::Shell`.  This makes it a bit more flexible.
2022-11-24 09:47:33 -06:00
Ed Page
ed683ef248 fix: Always expose ColorChoice 2022-11-24 09:47:33 -06:00
Jan Christian Grünhage
aaac3c4930
chore: Replace atty with is-terminal 2022-11-24 15:33:43 +01:00
Ed Page
623ccbc152 style: Make clippy happy 2022-11-24 08:05:21 -06:00
Alex Saveau
fd64c8ae93
Gate term_width and max_term_width APIs on wrap_help 2022-11-20 19:33:02 -08:00
Ed Page
44dd8ea4c5 fix: Correctly refer to unstable-v5 2022-11-17 10:09:45 -06:00
Ed Page
dd143eed47 fix: Make ArgPredicate non_exhaustive in v5
Didn't want to forget to do this

Inspired by #4487
2022-11-17 09:01:51 -06:00
Peter Grayson
d9c9c7bdd8
fix: ContextKind.as_str() spellings
Signed-off-by: Peter Grayson <pete@jpgrayson.net>
2022-11-16 11:14:54 -05: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
c939de8a25 fix: Don't panic on non-built arg rendering
For num_args, we'll just use the default

Fixes #4479
2022-11-14 12:13:18 -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
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
539577dfb2 refactor(help): Remove dead code
`longest` is always the same or longer than the `sc_str.display_width`
2022-11-07 10:27:17 -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
Thayne McCombs
2ff3d43724 feat(derive): Implement ValueEnum for ColorChoice 2022-11-04 00:29:52 -06:00
Ed Page
e11afa284b
Merge pull request #4401 from epage/last
fix(complete): Support last(true) with CommandWithArguments
2022-10-18 07:41:02 -05:00
Ed Page
1ead5ef421 fix(complete): Support last(true) with CommandWithArguments
Fixes #4400
2022-10-18 07:28:52 -05:00
Justin Browne
a1d4476f24 Fix a broken link in ValueEnum docs 2022-10-18 05:03:58 -04: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
0f3c98a799 fix(error): Be consistent in puncutation 2022-10-13 13:56:58 -05:00
Ed Page
b9d298086c refactor(error): Move subcommand suggestion to general suggestions 2022-10-13 13:17:44 -05:00
Ed Page
63eec40652 refactor(error): Clarify distinct suggestion cases 2022-10-13 13:15:11 -05:00
Ed Page
5275660967 refactor(error): Move escape suggestion to general suggestion 2022-10-13 13:10:15 -05:00
Ed Page
813060ea82 refactor(error): Move bad-escape suggestion to general suggestion 2022-10-13 13:03:14 -05:00
Ed Page
7417c75c57 refactor(error): Move escaped-subcmd suggestion to general suggestions 2022-10-13 12:59:13 -05:00
Ed Page
c8cb5bba38 feat(error): General suggestion mechanism 2022-10-13 12:20:04 -05:00
Ed Page
4ec79b1448 refactor(error): Centralize suggestions 2022-10-13 12:12:03 -05:00
Ed Page
a4bcba6840 fix(error): Consistently indent suggestions 2022-10-13 12:10:13 -05:00
Ed Page
47704314b1 refactor(error): Consolidate 'did you mean' code 2022-10-13 11:11:17 -05:00
Ed Page
a964f45b1b fix(error): Properly quote, color subcommand suggestions 2022-10-13 10:51:17 -05:00
Ed Page
1039c61c53 fix(error): Be more consistent in error quoting 2022-10-13 10:45:38 -05:00
Ed Page
f8053fcedb fix(error): Don't suggest '--' when it doesn't help 2022-10-13 10:17:11 -05:00
Ed Page
06e2388972 docs: Clarify default_values_ifs tuple parameters
Fixes #4376
2022-10-12 14:11:40 -05:00
Ed Page
d0dcaac2ab fix(parser): Only add ArgGroup to ArgMatches for command-line
This will fix `clap_derive`s behavior for optional-flattened groups as
it will properly detect when the group is present (#3566).

While I consider this a bug and not part of compatibility guarentees, I
still want to keep in mind user impact which could still prevent this.
Defaults will make the group always-present which has little value and
if anything is relying on this, it is probably an application bug.
2022-10-12 07:52:07 -05:00
Ed Page
e98fc7f6eb refactor(parser): Centralize knowledge for explicit 2022-10-12 07:46:39 -05:00
Ed Page
e704adb4ff refactor(parser): Centralize group handling
Since groups are only associated with the occurrence, we can move the
assigning of it to the occurrence start.

This will help centralize other checks
2022-10-12 07:37:41 -05:00