fix(help): render partially optional values with [] in help output#6376
Closed
kimjune01 wants to merge 1 commit into
Closed
fix(help): render partially optional values with [] in help output#6376kimjune01 wants to merge 1 commit into
kimjune01 wants to merge 1 commit into
Conversation
When an option has multiple value names with num_args allowing fewer
values than names (e.g. num_args(1..=2) with value_names(["FOO", "BAR"])),
values beyond the minimum count are now rendered as optional:
--example <FOO> [BAR]
Previously all values were shown as required regardless of num_args.
Fixes clap-rs#4847
Author
|
Closing this draft. It isn't backed by a passing regression test on our side, so we'd rather not leave an unvalidated draft open. Thanks for the earlier feedback on #6370. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
num_args.min_values()now render as[name]instead of<name>in help output, correctly indicating they are optionalmin_vals==0wraps none (caller already wraps entire suffix), elsemin_valsis the cutoffFixes #4847
Test plan
cargo test: 934 tests across 9 suites, 0 failuresoption_display3assertion to match new behavioroption_display_partially_optional_values,option_display_partially_optional_require_equals,option_display_partially_optional_three_valuesHypothesis graph
https://github.com/kimjune01/sweep/blob/master/repo-hypotheses/clap-rs-clap.md