Repository navigation
Conversation
CompileCommand::script_type was a String limited by value_parser, so clap already rejected anything else and the "Invalid script type" match arm was unreachable. Make it a ScriptType enum deriving clap::ValueEnum, like DatabaseType, so the match is exhaustive and the allowed values live in one place. The accepted values (sh, wsh, sh-wsh, tr), the default and the --help output are unchanged. Closes bitcoindevkit#345. Co-authored-by: Claude <noreply@anthropic.com>
Collaborator
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.
Description
Closes #345.
CompileCommand::script_typewas aStringlimited byvalue_parser, so clap already rejected anything else and the_ =>arm returning "Invalid script type" was unreachable. It is now aScriptTypeenum derivingclap::ValueEnum(Sh,Wsh,ShWsh,Tr), followingDatabaseTypeinsrc/persister.rs, and thematchis exhaustive.Notes to the reviewers
The CLI surface is unchanged: the accepted values are still
sh,wsh,sh-wsh,tr(defaultwsh,TYPEenv var kept), an invalid value is still rejected by clap with the same list of possible values, andbdk-cli compile --helpis byte-identical before and after. I left the variants without doc comments on purpose, since clap would otherwise switch the help to a per-value list.Tests:
wsh, andpkhis rejected;cargo test --features compiler --bins(17 passed) and thecompileintegration tests (cargo test --features compiler --test cli compile, 3 passed);compiler) still compiles;cargo fmtandcargo clippy --features compiler --all-targetsare clean.Checklists
All Submissions:
cargo fmtandcargo clippybefore committing