fix: refactor android feature validation to isolate cli errors from requ - #452
Merged
cdsap merged 1 commit intoSep 7, 2026
Merged
Conversation
cdsap
deleted the
issue/451-hermes-refactor-android-feature-validation-a1
branch
September 7, 2026 23:41
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.
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.ktcli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/Main.ktcli/src/test/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectsCliTest.ktVerification
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheck