fix(gen): Ensure subcommands are post-processed #2863
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
App::get_matches
lazily post-processesApp
s andArg
s so we don'tdo it to subcommands that are never run (downside being people have to
exercise their full app to get debug_asserts).
clap_generate
was only post-processing the top-levelApp
andArg
s,ignoring the sub-commands. In #2858, we noticed that
--version
wasbeing left in the completions instead of being removed during the
_build
step. We would also have an incorrectnum_vals
and a host ofother problems.
This change adds a
App::_build_all
function forclap_generate
to useto eagerly build everything. By having it there, we make sure
everywhere that needs eager building, gets it (like some tests).
In
clap_generate::utils
, we add a unit test to ensure the subcommand's--version
was removed.For some other tests specifying
.version()
, I addedAppSettings::PropagateVersion
to make it behave more consistently.The places I didn't were generally where the version was conditionally
set.
For
clap_generate/tests/generate_completions.rs
, I had to adjust theconflicts_with
because the subcommand was inheriting the argument withit defined but the subcommand did not have the argument, tripping up a
debug assert.
Fixes #2860