Skip to content

fix: refactor android feature validation to isolate cli errors from requ - #452

Merged
cdsap merged 1 commit into
mainfrom
issue/451-hermes-refactor-android-feature-validation-a1
Sep 7, 2026
Merged

fix: refactor android feature validation to isolate cli errors from requ#452
cdsap merged 1 commit into
mainfrom
issue/451-hermes-refactor-android-feature-validation-a1

Conversation

@cdsap

@cdsap cdsap commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

Problem

cli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectRequest.kt:3 imports Clikt UsageError, and validateAndroidOnlyFeatures at lines 96-106 throws CLI-framework exceptions from the request-resolution code used by GenerateProjectRequest.resolve at lines 47-92. Main.kt lines 57-81 is the actual Clikt command boundary, while GenerateProjectRequest also resolves project name, Gradle version, output path, Develocity enablement, and versions overrides. Tests in cli/src/test/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectsCliTest.kt:52-108 assert UsageError directly from GenerateProjectRequest.resolve, so the framework coupling is now part of lower-level resolver behavior.

Why this matters

The request resolver is close to an application/service boundary: it turns parsed inputs into a ProjectGenerator request. Having it construct Clikt exceptions makes that behavior harder to reuse from another adapter, such as the backend or tests that want pure request validation, and forces non-CLI logic to depend on CLI presentation concerns.

Proposed change

Introduce a tiny CLI-domain validation result for Android-only feature compatibility, for example an internal ProjectFeatureCompatibility or GenerateProjectRequestValidation helper that returns a violation message or throws a small project-local exception. Keep UsageError creation in GenerateProjects.run, or in a thin Clikt adapter around GenerateProjectRequest.resolve. Preserve the existing messages and behavior for CLI users. Update GenerateProjectsCliTest so command parsing still expects UsageError, while direct resolver/validation tests assert the project-local validation result or exception instead of Clikt.

Notes

DDD/clean architecture lens: keep the application request assembly and feature compatibility policy independent from the Clikt delivery mechanism. This is a small adapter-boundary cleanup, not a redesign.

Fixes #451

Changes

  • cli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectRequest.kt
  • cli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/Main.kt
  • cli/src/test/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectsCliTest.kt

Verification

  • ./gradlew :project-generator:unitTest
  • ./gradlew :cli:test
  • ./gradlew ktlintCheck

@cdsap
cdsap merged commit 83c49b7 into main Sep 7, 2026
14 checks passed
@cdsap
cdsap deleted the issue/451-hermes-refactor-android-feature-validation-a1 branch September 7, 2026 23:41
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.

Refactor Android feature validation to isolate CLI errors from request resolution

1 participant