clap/tests/builder
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
..
action.rs
app_settings.rs fix: Make long subcommand flag inference consistent 2023-09-25 13:28:27 -07:00
arg_aliases.rs
arg_aliases_short.rs
arg_matches.rs
borrowed.rs
cargo.rs
command.rs
conflicts.rs chore: Inline simple non-mixed format args 2023-05-04 15:58:04 -04:00
default_missing_vals.rs fix(assert): Allow stateful value parsers 2023-07-18 14:11:56 -05:00
default_vals.rs fix(assert): Allow stateful value parsers 2023-07-18 14:11:56 -05:00
delimiters.rs
derive_order.rs
display_order.rs
double_require.rs chore: Inline format args using clippy fix 2023-05-03 21:49:11 -04:00
empty_values.rs
env.rs
error.rs fix(builder): UnknownValueParser shouldn't error on flag absense 2023-08-18 14:29:37 -05:00
flag_subcommands.rs
flags.rs fix(error): Change from neutral 'note' to helpful 'tip' 2023-03-27 20:45:11 -05:00
global_args.rs
groups.rs
help.rs fix(help): Hide 'help' if only flattened subcommand 2023-11-27 10:49:21 -06:00
help_env.rs
hidden_args.rs fix(help): Fix --help help text in edge case (#4710) 2023-02-15 10:25:19 -06:00
ignore_errors.rs fix(ignore_errors): Allow help and version command 2023-06-28 08:58:40 +08:00
indices.rs
main.rs
multiple_occurrences.rs style: Make clippy happy 2023-10-12 08:32:59 -05:00
multiple_values.rs fix(assert): Call out the action in positional assert 2023-09-25 10:18:37 -05:00
occurrences.rs
opts.rs fix: Broken long arg inference on conflicts 2023-06-17 13:30:05 -07:00
positionals.rs chore: Inline format args using clippy fix 2023-05-03 21:49:11 -04:00
posix_compatible.rs
possible_values.rs perf: Avoid retrieving possible_values unless used 2023-12-28 10:06:35 -06:00
propagate_globals.rs feat: Allow deferred initialization of subcommands 2023-06-09 08:29:38 -05:00
require.rs
subcommands.rs fix(parser): Don't suggest -- as often 2023-07-21 14:27:15 -05:00
template_help.rs
tests.rs chore: Inline format args using clippy fix 2023-05-03 21:49:11 -04:00
unicode.rs
unique_args.rs
utf8.rs
utf16.rs
utils.rs chore: Make format!() calls more readable 2023-01-29 19:14:47 +00:00
version.rs feat: Allow deferred initialization of subcommands 2023-06-09 08:29:38 -05:00