-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace broken open-coding of
FromStr
with derive(clap::ValueEnum)
(
#197) 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 on `clap`'s excellent `ValueEnum` 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: ❯ cargo r -- build -h ... Usage: x build [OPTIONS] Options: ... --platform <PLATFORM> Build artifacts for target platform [possible values: android, ios, linux, macos, windows] --arch <ARCH> Build artifacts for target arch [possible values: arm64, x64] ... --format <FORMAT> Build artifacts with format [possible values: aab, apk, appbundle, appdir, appimage, dmg, exe, ipa, msix] --store <STORE> Build artifacts for target app store [possible values: apple, microsoft, play, sideload] Finally, we also utilize its generated `PossibleValue::get_name()` to implement our open-coded `Display` implementations, ensuring any renames via clap attributes trickle through into how we print them.
- Loading branch information
Showing
1 changed file
with
25 additions
and
106 deletions.
There are no files selected for viewing
This file contains 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