Commit graph

1194 commits

Author SHA1 Message Date
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
eb53db89f8 feat(help): Stabilize styling support
Fixes #3234
2023-08-28 09:49:48 -05:00
Ed Page
d30d94f51c chore: Update MSRV to 1.70 2023-08-24 10:14:23 -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
Ed Page
76b891db41 test(parser): Reproduce suggestion 2023-07-21 14:21:45 -05:00
Ed Page
8b536e2719 fix(help): Wrap long possible values correctly
We weren't taking the name into account when determining the wrap width.

Fixes #5022
2023-07-19 10:42:09 -05:00
Ed Page
4caa536ca4 fix(assert): Allow stateful value parsers
We'll need to re-evaluate how to solve #3202.

Fixes #4643
2023-07-18 14:11:56 -05:00
Ed Page
97f4c72af1 test(examples): Verify all features 2023-07-17 17:01:31 -05:00
Ed Page
0ba987fca9 refactor(test): Make it easier to compare features with manifest 2023-07-17 16:57:22 -05:00
Ed Page
36afe99bfa fix(help): Skip [OPTIONS] if help/version action
Our code for detecting when to skip this in the usage was never updated
for actions.
2023-07-17 10:40:42 -05:00
Ed Page
22b545b98b feat(help): Explicit control over short/long help
Fixes #4687
2023-07-17 10:37:26 -05:00
Ed Page
bc000aa4b0 fix(help): Defaulting max_term_width instead of max_term_width
Fixes #4295
2023-07-17 09:40:49 -05:00
Sebastian Toh
8103e9760a fix(ignore_errors): Allow help and version command 2023-06-28 08:58:40 +08:00
Sebastian Toh
d451e0a60c test(ignore_errors): Add help & version cmd tests 2023-06-28 08:55:10 +08:00
Alex Saveau
f9994bff47
fix: Broken long arg inference on conflicts
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-06-17 13:30:05 -07:00
Ed Page
d10938dd33 feat: Allow deferred initialization of subcommands
This is mostly targeted at reducing startup time for no-op commands
within *very* large applications, like deno (see #4774).

This comes at the cost of 1.1 KiB of binary size
2023-06-09 08:29:38 -05:00
Ed Page
103ae5cf62 fix(derive): Don't warn when people bring types into scope
Fixes #4951
2023-06-05 12:55:06 -05:00
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