Replace broken open-coding of FromStr
with derive(clap::ValueEnum)
#197
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.
Fixes #194, closes #196, CC @SolidTux for testing.
We've seen that
impl FromStr for Format
missed the"exe"
match arm in parsing (#194) despite being listed in the allowed values in our top-level documentation and help text.Instead of fixing this mistake, remove open-coded
FromStr
entirely and rely onclap
's excellentValueEnum
derive. This not only generates a complete parser (with the option for attributes to change variant names) but also automates generation of a list of possible values, getting rid of any ambiguity/duplication/copy-paste errors we might have or create in the future:Finally, we also utilize its generated
PossibleValue::get_name()
to implement our open-codedDisplay
implementations, ensuring any renames via clap attributes trickle through into how we print them.