Commit graph

378 commits

Author SHA1 Message Date
Ed Page
360bb3bc11 fix(help): Properly wrap subcommand about
Fixes #5607
2024-07-31 16:17:40 -05:00
Ed Page
58b5bd89ea test(help): Show bad subcommand wrapping 2024-07-31 16:17:40 -05:00
Ed Page
7b5b61b021 test(help): Switch to snapbox 2024-07-31 15:58:24 -05:00
Zanie Blue
2eb842cc3b feat: Show user defined help flags in hints
This allows display of user-defined help flags during "try 'help'" style
messages
2024-07-08 19:01:22 -05:00
Zanie Blue
b24deb101f test: Add coverage for help flag hints 2024-07-08 19:01:22 -05:00
Ed Page
cf5c95862e fix(parser): Report correct num_args on too-few
Fixes #5526
2024-06-10 09:16:53 -05:00
Ed Page
e0c9619c27 test(parser): Snapshot num_args errors 2024-06-10 09:15:48 -05:00
Ed Page
08656d046e fix(parser): Allow exclusive to override required_*
There are other cases for `required` that aren't being handled
- Groups
- Conflicts

I'm concerned there might be weird corner cases and didn't want the
analysis for that to block fixing this.

Fixes #5507
2024-06-06 15:01:04 -05:00
Ed Page
65e90cd31f test(parser): Show conditional requireds and exclusive 2024-06-06 14:56:40 -05:00
Ed Page
75e2199415 chore: Upgrade snapbox 2024-05-24 10:13:50 -05:00
Ed Page
800d7cb8ad chore: Update from template 2024-05-14 12:27:02 -05:00
Ed Page
446328a8d3 fix(error): Include -- in more cases
Inspired by rust-lang/cargo#12494.
Part of this is that our "did you mean" does prefix checks so it can be
overly aggressive in providing suggestions.
To avoid providing needless suggestions I limited this change to `last`
/ `trailing_var_arg` as those convey that `--` is more likely a valid
suggestion.
2024-02-16 06:54:57 -06:00
Ed Page
7de6df8782 test(error): Show existing last behavior 2024-02-16 06:41:45 -06:00
Ed Page
5f9cecb6bd chore: Update snapbox/trycmd 2024-02-14 16:44:57 -06:00
Ed Page
f529ec398c fix(parser): Ensure subcommand flags can conflict
Fixes #5297
2024-01-11 10:25:57 -06:00
Ed Page
a7e04a53e4 fix(parser): Improve subcommand conflict error 2024-01-11 10:20:19 -06:00
Ed Page
69c0509198 test(parser): Verify conflicts with precedence 2024-01-11 09:14:37 -06:00
Ed Page
e2b18f199f test(parser): Show flag behavior 2024-01-11 09:04:35 -06:00
Ed Page
06bff1c955 test(parser): Check subcommands conflict with positionals 2024-01-11 08:48:23 -06:00
Ed Page
70da3a8608 test(parser): Reduce size of test 2024-01-11 08:46:47 -06:00
Ed Page
11fd6ca269 test(parser): Clarify test name 2024-01-11 08:45:40 -06:00
Ed Page
811acc45c1 test(parser): Group subcommandc conflict tests 2024-01-11 08:45:03 -06:00
Sean Allred
05cd057978
perf: Avoid retrieving possible_values unless used
In some sophisticated situations, these may be expensive to calculate.
One example might be a '--branch' option accepting any single Git
branch that exists on the remote -- in such a case, the remote would
need to be queried for all possible_values. The cost is ultimately
unavoidable at runtime since this validation has to happen eventually,
but there's no need to pay it when generating help text if
`is_hide_possible_values_set`.

To keep '-h' fast, avoid collecting `possible_values` during '-h'
unless we're actually going to use the values in display.

This optimization is repeated for the manpage renderer.

This is trivially based on the short-circuiting logic at [1], which at
least supports the idea that actually consuming the iterator is not
generally-guaranteed behavior when `hide_possible_values` is set.

Note on the 'expensive' mod: This keeps all the possible_values tests
in one file but allows the entire set of tests to be controlled by the
'strings' feature (which is required to be able to use String rather
than str for each possible value).

[1]: clap_builder/src/builder/command.rs:long_help_exists_
2023-12-28 10:06:35 -06:00
Ed Page
b13f6d9862 fix(help): Hide 'help' if only flattened subcommand 2023-11-27 10:49:21 -06:00
Ed Page
a9322cabf3 fix(help): Hide subcommands in flattened usage 2023-11-27 10:43:16 -06:00
Ed Page
b6561983a0 test(help): Show how hide and flatten mix 2023-11-27 10:38:05 -06:00
Ed Page
22130e3057 fix(help): Use right about when flattening
Fixes #5226
2023-11-27 09:28:30 -06:00
Ed Page
e9194b55e2 test(help): Better show about bug 2023-11-27 09:23:38 -06:00
Ed Page
9c0f7a7253 fix(help): Recurse help flattening 2023-11-09 15:34:05 -06:00
Ed Page
c9a7ef06e1 fix(help): Gloss over globals with flatten
When using globals, people tend to make all of the top-level arguments
global and cascading them through would just bloat the output.
2023-11-09 15:33:18 -06:00
Ed Page
9e5f93d43f fix(help): Be consistent in long/short help 2023-11-09 15:33:18 -06:00
Ed Page
66d2bcbdd4 feat(help): Allow flattening help 2023-11-09 15:32:57 -06:00
Ed Page
caf5cdcfa0 feat(help): Allow flattening usage 2023-11-09 13:31:22 -06:00
Ed Page
a1fd922bda feat(help): Allow controlling flattening 2023-11-09 13:31:11 -06:00
Ed Page
dfebb54423 style: Make clippy happy 2023-10-12 08:32:59 -05:00
Ed Page
3ac44040ef
Merge pull request #5025 from SUPERCILEX/resolve-alias-conflicts
fix: Resolve conflicting name inference if from aliases
2023-09-25 15:56:28 -05:00
Alex Saveau
a76789eb8b
fix: Make long subcommand flag inference consistent
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-09-25 13:28:27 -07:00
Alex Saveau
c2b8ec3bd3
fix: Resolve conflicting name inference if from aliases
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-09-25 13:18:54 -07:00
Alex Saveau
e5c6993cca
test: Long flags inference
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-09-25 13:18:50 -07:00
Ed Page
221177b9cb fix(assert): Call out the action in positional assert
Brought up in #5135
2023-09-25 10:18:37 -05:00
Ed Page
bf3f25ebb2 fix(help): Ensure padding isn't stripped
Fixes #5083
2023-08-22 16:02:33 -05:00
Ed Page
afefdc9414 test(help): Show padding bug 2023-08-22 16:00:10 -05:00
Ed Page
56135f3ff3 fix(builder): UnknownValueParser shouldn't error on flag absense
Fixes #5079
2023-08-18 14:29:37 -05:00
Ed Page
b55ebc9f7f test(parser): Show bad Unknown bug on flags 2023-08-18 14:19:54 -05:00
Ed Page
9f65eb0c9a refactor(error): Give caller control over suggestion 2023-08-16 14:54:45 -05:00
Ed Page
8413c155d2 feat(builder): Allow injecting known unknowns
Fixes #4706
2023-08-16 14:50:08 -05:00
Roland Fredenhagen
f16a1a76bc
chore: Clippy 2023-07-26 23:48:37 +07:00
Ed Page
8bee728034 fix(parser): Value terminator has higher precedence than later multiple values
This is one of several bugs found when looking at #4960.
2023-07-21 16:41:08 -05:00
Ed Page
bdf205bff2 test(parser): Show one value terminator bug 2023-07-21 16:05:38 -05:00
Ed Page
6590a855ee fix(parser): Don't suggest -- as often
See #2766
2023-07-21 14:27:15 -05:00