Commit graph

209 commits

Author SHA1 Message Date
Ed Page
0a635b9a20 fix(parser): Don't duplicate requireds when usage disabled
Skipping a test for now because we don't have a mixed-feature testing
strategy.

Fixes #5312
2024-01-16 14:15:48 -06:00
Ed Page
ef98da27cb chore: Release 2024-01-15 10:20:03 -06:00
Ed Page
50c59f63bb fix(parser): Don't panic with conflicts and groups
With #5298, I had overlooked that `matcher.arg_ids()` includes
`ArgGroup`s.  I had assumed I could always find a present `id` among
`Arg`s and `unwrap`ed.

I skipped a test for this because the use case is a bit strange that the
long term value for the test would likely be low.
If/when we add derive support for `args_conflicts_with_subcommands`, it
will then cover this case.

Fixes #5304
2024-01-15 09:30:19 -06:00
Ed Page
cbc9c9dd44 chore: Release 2024-01-11 20:52:38 -06:00
Ed Page
2a3356a535 fix: Update anstream 2024-01-11 20:33:39 -06:00
Ed Page
12b5c39d46 chore: Release 2024-01-11 10:37:53 -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
ea00ef3051 refactor(error): Allow more conflict sources 2024-01-11 10:17:35 -06:00
Ed Page
e47d8a2a66 refactor(parser): Clarify arg error 2024-01-11 09:47:00 -06:00
Ed Page
514f28bc92 chore: Release 2024-01-08 10:39:47 -06:00
Ed Page
3eaf1af052 fix(help): Correctly show help for fake flags 2024-01-08 09:58:42 -06:00
Ed Page
148e102ac3 fix(builder): Allow custom flag definitions
The goal is to allow getting the position of repeated flags for #5287
2024-01-08 09:49:43 -06:00
Ed Page
6d601e6f31 chore: Release 2023-12-28 12:07:48 -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
d092896d61 chore: Release 2023-12-04 12:17:32 -06:00
Ed Page
37917be0b7 feat: Add Command::mut_group
Fixes #5038
2023-12-04 12:03:05 -06:00
Ed Page
21b671f689 chore: Release 2023-11-27 11:57:26 -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
22130e3057 fix(help): Use right about when flattening
Fixes #5226
2023-11-27 09:28:30 -06:00
Kelly Thomas Kline
7568d5fa67
Update command.rs
Correct wording.
2023-11-16 21:06:03 -08:00
Ed Page
3aeea916e8 chore: Release 2023-11-10 16:24:46 -06:00
Ed Page
9c0f7a7253 fix(help): Recurse help flattening 2023-11-09 15:34:05 -06:00
Ed Page
4bef91ca3c refactor(help): Pull out flat subcommands 2023-11-09 15:34:03 -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
2142b136b8 refactor: Pull out usage name fallback 2023-11-09 13:27:59 -06:00
Ed Page
4b60cefbf1 refactor: Pull out bin name fallback 2023-11-09 13:26:20 -06:00
Ed Page
c1c2e95ab6 refactor(help): Pull out subcommand usage logic 2023-11-09 12:52:08 -06:00
Ed Page
d9685bcc71 refactor(help): Bypass outer usage layer 2023-11-09 12:52:08 -06:00
Ed Page
25e3a87d3c refactor(help): Consolidate arg line usage generation 2023-11-09 12:14:25 -06:00
Ed Page
83981a7f7b refactor: Pull out arg usage line 2023-11-09 12:08:24 -06:00
Ed Page
0c668c3915 refactor(help): Pull out bin name logic 2023-11-09 12:03:35 -06:00
Ed Page
7472aba6ce refactor(help): Clarify usage condition 2023-11-09 12:00:52 -06:00
Ed Page
676e934a61 refactor(help): More directly write args 2023-11-09 11:57:15 -06:00
Ed Page
acdd2c33f0 refactor(help): Make usage argument order consistent 2023-11-09 11:50:46 -06:00
Ed Page
da98eb1a05 refactor(help): Pull out top-level usage logic 2023-11-08 11:49:07 -06:00
Ed Page
f50800f763 refactor(help): Only trim the end on usage 2023-11-08 11:42:54 -06:00
Ed Page
f04f04111b refactor(help): Switch usage creation to writing 2023-11-08 11:25:43 -06:00
Ed Page
6f7174cc7c refactor(help): Pull out usage separator 2023-11-08 11:10:55 -06:00
Ed Page
28425e484f style(docs): Resolve warnings 2023-11-07 13:44:41 -06:00
Ed Page
9bfa5a338c chore: Release 2023-10-24 13:25:07 -05:00
Ed Page
38b5a2f956 chore: Release 2023-10-24 11:45:21 -05:00
Alex Crichton
9a9aabc178 refactor: Reduce code size of testing tokens if they're a number
This commit is a tiny win in compiled code size of a final binary
including `clap` which shaves off 19k of compiled code locally.
Previously tokens were checked if they were a number by using
`.parse::<f64>().is_ok()`, but parsing floats is relatively heavyweight
in terms of code size. This replaces the check with a more naive "does
this string have lots of ascii digits" check where the compiled size of
this check should be much smaller.
2023-10-24 09:17:45 -07:00
Kevin Reid
71c1e59334 docs: Fix doc link to Arg::trailing_var_arg 2023-10-14 18:11:33 -07:00
Ed Page
dfebb54423 style: Make clippy happy 2023-10-12 08:32:59 -05:00