Skip to content

Preserve CLI unit spellings in Clap support - #1370

Merged
adamchalmers merged 3 commits into
mainfrom
codex/clap-unit-spellings-1369
Sep 7, 2026
Merged

Preserve CLI unit spellings in Clap support#1370
adamchalmers merged 3 commits into
mainfrom
codex/clap-unit-spellings-1369

Conversation

@JordanNoone

@JordanNoone JordanNoone commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Enabling the unit enums' new clap feature rejects existing abbreviations such as m, kg, and kg:m3, including the CLI's own default arguments. UnitVolume also lacks ValueEnum, and enabling this feature alone fails to compile because Clap's required std feature is disabled.

Preserve the existing 31 unit spellings and density aliases, add ValueEnum to UnitVolume, and enable clap/std. Parsing stays on the modeling-command enums without API-to-modeling conversions. Clap remains optional.

This PR completes the Clap unit support merged in #1369, targets main, and supports KittyCAD/cli#1844.

Validation:

  • Two focused parsing tests pass, covering all six unit enums and density aliases.
  • cargo +1.98.1 check -p kittycad-modeling-cmds --no-default-features --locked --offline passes.
  • cargo +1.98.1 clippy -p kittycad-modeling-cmds --features clap --all-targets --locked --offline -- -D warnings passes.
  • Formatting passes.
  • The CLI consumer's seven focused tests pass with this fix; three of those tests fail against the unmodified UoM can be parsed by Clap #1369 head because volume diagnostics and analysis defaults are broken.

adamchalmers and others added 2 commits September 6, 2026 21:58
Allow units-of-measure types (e.g. volume, length)
to be used by `clap` for deserializing command
line args from strings into those enums.
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@aec3f6e). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1370   +/-   ##
=======================================
  Coverage        ?   35.73%           
=======================================
  Files           ?       37           
  Lines           ?     1858           
  Branches        ?        0           
=======================================
  Hits            ?      664           
  Misses          ?     1194           
  Partials        ?        0           
Flag Coverage Δ
unittests 35.73% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from achalmers/units-clap to main September 7, 2026 04:07
@JordanNoone
JordanNoone marked this pull request as ready for review September 7, 2026 04:15

Copy link
Copy Markdown
Contributor Author

@adamchalmers ready for review. Resolved the conflict with main after #1369 landed.

Changes here:

  • Added Clap ValueEnum support to UnitVolume.
  • Preserved existing unit spellings (mm3, m2, kg, etc.) and density aliases so current arguments and defaults keep working.
  • Enabled Clap’s required std feature while keeping the dependency optional.
  • Added regression coverage for all six unit enums and density aliases.

KittyCAD/cli#1844 now parses directly into the modeling-command enums and removes the conversion helper, as requested. All 11 checks pass on efad232.

@adamchalmers
adamchalmers merged commit 13db0fc into main Sep 7, 2026
11 checks passed
@adamchalmers
adamchalmers deleted the codex/clap-unit-spellings-1369 branch September 7, 2026 04:46
JordanNoone pushed a commit that referenced this pull request Sep 7, 2026
# Changed

 - Clap strings for UoM should match serde/display strings (#1370)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants