Repository navigation
refactor(compile): use ValueEnum for script type - #346
chukwudiikeh wants to merge 2 commits into
Conversation
Replace the String script_type in CompileCommand with a ScriptType enum deriving clap::ValueEnum. The match in execute is now exhaustive, so the unreachable fallback arm is removed. No CLI behavior change.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #346 +/- ##
==========================================
- Coverage 61.43% 61.41% -0.02%
==========================================
Files 23 23
Lines 3993 3989 -4
==========================================
- Hits 2453 2450 -3
+ Misses 1540 1539 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vadim-anfv
left a comment
There was a problem hiding this comment.
tACK 36e41a3
Ran compile with every --type value, works as before.
Nit, non-blocking: for future commits, the body is usually wrapped at 72 chars (see the guidelines linked in CONTRIBUTING.md).
|
Thanks for the review and for testing, @vadim-anfv. Noted on the commit body, I'll wrap at 72 characters in future commits. |
The existing compile tests only exercise wsh and tr. Add a test for the sh and sh-wsh branches so every ScriptType variant is covered.
|
I've pushed a second commit adding a test for the sh and sh-wsh branches, to address the Codecov patch coverage report. @vadim-anfv, could you take another look when you have time? |
Description
This PR replaces the
Stringscript_typeinCompileCommandwith aScriptTypeenum derivingclap::ValueEnum. The goal is to make thematchinexecuteexhaustive and keep the list of accepted script types in one place, instead of repeating it in the argument definition and in the match.Fixes #345
Notes to the reviewers
The change is limited to
src/handlers/descriptor.rsand follows the existingDatabaseTypeenum insrc/persister.rs.ScriptTypeenum with the variantsSh,Wsh,ShWshandTr, gated behind thecompilerfeature like the rest of thecompilecommand.script_typefromStringtoScriptType, replacing the hand-writtenvalue_parserlist withvalue_enum.matchinexecutenow matches on the enum variants._ =>arm returning "Invalid script type", which was unreachable because clap already rejects any other value.There is no CLI behavior change. clap renders the variants in kebab-case, so
--typestill acceptssh,wsh,sh-wshandtr, the default is stillwsh, and theTYPEenv var still works.I checked manually that
compile --type sh-wshproduces the same descriptor before and after the change, and the existingcompiletests pass.Changelog notice
None. This is an internal refactor with no user-facing change.
Checklists
All Submissions:
cargo fmtandcargo clippybefore committing