refactor(args): finish shared option helpers (#86) #101

Merged
gronod merged 1 commits from feat/86-args-builder-completion into milestone/m8-consolidation 2026-09-11 12:20:38 +01:00
Owner

Summary

Phase 5 of the M8 consolidation plan — completes the ArgsBuilder adoption across the remaining argument generators and locks down the colour wire-format contract.

ArgsBuilder helper adoption (byte-identical argv)

All generated argv arrays remain strictly byte-identical with exact flag ordering preserved; every existing golden argv fixture passes unchanged.

  • TargenArgs: optionUnlessApprox for -N (skip ≈0.50), -V (skip ≈1.0), and -p (skip ≈1.0, retains the p > 0 guard); optionIfNonEmpty for the -c preconditioning profile; flag for -G; option for -A adaptation (still emitted even at 0.10 — no default-skip).
  • PrinttargArgs: flag for the -r raster layout; optionIfNonEmpty for the -d label and the dynamic -K/-I calibration value. CalibrationIdentity.isCalibration protection is fully retained — CAL_ basenames never get -K/-I.
  • PrintcalArgs: flag for -I (noInkLimit) and -z (verify); optionIfNonEmpty for the -a previous-calibration path. Numeric validation (-m TAC, -x{C|M|Y|K}) and output order unchanged.
  • ColprofArgs: unchanged — the FWA tri-state (none → omit, "" → bare -f, path → passthrough) and none viewing-condition skips cannot be represented by the helpers without altering argv, so those branches stay explicit per the contract.

No builder/config types were merged; no generic flag table introduced. ArgsBuilder.swift itself needed no changes — the helpers already existed but were unused.

New tests

  • ArgsBuilderTests (new suite, 13 tests): direct coverage of each helper — option (nil/present/empty verbatim), optionIfNonEmpty (nil/empty/whitespace-only/trim), optionUnlessApprox (nil, exact skip, within epsilon, outside epsilon, POSIX-locale formatting, custom epsilon/format), flag (true/false).
  • TargenArgsTests: whitespace-only and padded preconditioning profile cases.
  • PrinttargArgsTests: whitespace-only label and calibration values; trimming assertions.
  • PrintcalArgsTests: whitespace-only and padded previous-cal path cases.
  • ChartreadRowTests: decode of a row carrying both XYZ and Lab arrays; CIEXYZ/XYZColor and CIELab/LabColor encode as unkeyed three-number arrays; PatchColor preserves the XYZ/Lab keys on the wire.

Gate

xcodegen generate --spec project.yml && xcodebuild test -scheme ICCery -destination 'platform=macOS' -derivedDataPath build/DerivedData-feat-86-args-builder-completion ARCHS='arm64 x86_64' ONLY_ACTIVE_ARCH=NO CODE_SIGNING_ALLOWED=YES CODE_SIGN_IDENTITY='-' -only-testing:ICCeryCoreTests/ArgsBuilderTests -only-testing:ICCeryCoreTests/TargenArgsTests -only-testing:ICCeryCoreTests/PrinttargArgsTests -only-testing:ICCeryCoreTests/PrintcalArgsTests -only-testing:ICCeryCoreTests/ColprofArgsTests -only-testing:ICCeryCoreTests/ChartreadRowTests -only-testing:ICCeryCoreTests/ColourMathTests

TEST SUCCEEDED — 64 tests, 0 failures across 7 suites: ArgsBuilder (13), TargenArgs (14), PrinttargArgs (14), PrintcalArgs (5), ColprofArgs (9), ChartreadRow (5), ColourMath (5).

Refs #86

## Summary Phase 5 of the M8 consolidation plan — completes the ArgsBuilder adoption across the remaining argument generators and locks down the colour wire-format contract. ### ArgsBuilder helper adoption (byte-identical argv) All generated argv arrays remain strictly byte-identical with exact flag ordering preserved; every existing golden argv fixture passes unchanged. - **TargenArgs**: `optionUnlessApprox` for `-N` (skip ≈0.50), `-V` (skip ≈1.0), and `-p` (skip ≈1.0, retains the `p > 0` guard); `optionIfNonEmpty` for the `-c` preconditioning profile; `flag` for `-G`; `option` for `-A` adaptation (still emitted even at 0.10 — no default-skip). - **PrinttargArgs**: `flag` for the `-r` raster layout; `optionIfNonEmpty` for the `-d` label and the dynamic `-K`/`-I` calibration value. `CalibrationIdentity.isCalibration` protection is fully retained — `CAL_` basenames never get `-K`/`-I`. - **PrintcalArgs**: `flag` for `-I` (noInkLimit) and `-z` (verify); `optionIfNonEmpty` for the `-a` previous-calibration path. Numeric validation (`-m` TAC, `-x{C|M|Y|K}`) and output order unchanged. - **ColprofArgs**: unchanged — the FWA tri-state (`none` → omit, `""` → bare `-f`, path → passthrough) and `none` viewing-condition skips cannot be represented by the helpers without altering argv, so those branches stay explicit per the contract. No builder/config types were merged; no generic flag table introduced. `ArgsBuilder.swift` itself needed no changes — the helpers already existed but were unused. ### New tests - **`ArgsBuilderTests`** (new suite, 13 tests): direct coverage of each helper — `option` (nil/present/empty verbatim), `optionIfNonEmpty` (nil/empty/whitespace-only/trim), `optionUnlessApprox` (nil, exact skip, within epsilon, outside epsilon, POSIX-locale formatting, custom epsilon/format), `flag` (true/false). - **TargenArgsTests**: whitespace-only and padded preconditioning profile cases. - **PrinttargArgsTests**: whitespace-only label and calibration values; trimming assertions. - **PrintcalArgsTests**: whitespace-only and padded previous-cal path cases. - **ChartreadRowTests**: decode of a row carrying both `XYZ` and `Lab` arrays; `CIEXYZ`/`XYZColor` and `CIELab`/`LabColor` encode as unkeyed three-number arrays; `PatchColor` preserves the `XYZ`/`Lab` keys on the wire. ### Gate ``` xcodegen generate --spec project.yml && xcodebuild test -scheme ICCery -destination 'platform=macOS' -derivedDataPath build/DerivedData-feat-86-args-builder-completion ARCHS='arm64 x86_64' ONLY_ACTIVE_ARCH=NO CODE_SIGNING_ALLOWED=YES CODE_SIGN_IDENTITY='-' -only-testing:ICCeryCoreTests/ArgsBuilderTests -only-testing:ICCeryCoreTests/TargenArgsTests -only-testing:ICCeryCoreTests/PrinttargArgsTests -only-testing:ICCeryCoreTests/PrintcalArgsTests -only-testing:ICCeryCoreTests/ColprofArgsTests -only-testing:ICCeryCoreTests/ChartreadRowTests -only-testing:ICCeryCoreTests/ColourMathTests ``` **TEST SUCCEEDED** — 64 tests, 0 failures across 7 suites: ArgsBuilder (13), TargenArgs (14), PrinttargArgs (14), PrintcalArgs (5), ColprofArgs (9), ChartreadRow (5), ColourMath (5). Refs #86
gronod added 1 commit 2026-09-11 12:18:12 +01:00
Adopt ArgsBuilder helpers across the remaining argument generators while
preserving byte-identical argv and exact flag ordering:

- TargenArgs: optionUnlessApprox for -N/-V/-p, optionIfNonEmpty for -c,
  flag for -G, option for -A.
- PrinttargArgs: flag for -r, optionIfNonEmpty for -d and the dynamic
  -K/-I calibration value (CAL_ protection retained).
- PrintcalArgs: flag for -I/-z, optionIfNonEmpty for -a.
- ColprofArgs left explicit: FWA and "none" viewing-condition branches
  cannot be represented by the helpers without changing argv.

New ArgsBuilderTests cover nil/present/empty/whitespace/trim, epsilon
boundaries, POSIX formatting, and flag handling. Added whitespace-only
option cases for targen -c, printtarg -d/-K/-I, and printcal -a, plus
chartread row decode and unkeyed XYZ/Lab wire-encoding tests.

Refs #86

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
gronod self-assigned this 2026-09-11 12:18:44 +01:00
gronod added this to the M7 — Deduplicate & consolidate (develop) milestone 2026-09-11 12:18:44 +01:00
gronod merged commit 0298f69a2c into milestone/m8-consolidation 2026-09-11 12:20:38 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gronod/iccery-v2-mac#101