fix: refactor cli generation options to a request object - #425
Merged
cdsap merged 1 commit intoAug 27, 2026
Merged
Conversation
cdsap
deleted the
issue/424-hermes-refactor-cli-generation-options-to-a-a1
branch
August 27, 2026 20:24
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/Main.ktmixes Clikt option declarations with application-level generation mapping: enum conversion and Android-only validation at lines 63-72, versions/Gradle/path resolution at lines 73-100, and helper functions at lines 115-158. The tests incli/src/test/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectsCliTest.ktalready exercise pieces of that mapping directly, which shows this logic is more than command-line parsing.Why this matters
As new generation flags are added,
GenerateProjects.run()becomes the place where transport concerns, validation rules, defaults, and generator construction all change together. That raises the chance of precedence regressions such as CLI flags accidentally clearing values from--versions-file, and makes it harder to test generation-request behavior without instantiating a Clikt command.Proposed change
Introduce a small internal CLI-side request/config type, for example
GenerateProjectRequest, plus a mapper from parsedGenerateProjectsoptions to that type. MoveresolveVersions,resolveGradle,resolveProjectRootPath, project-name derivation, and Android-only feature validation behind that request-building boundary. KeepGenerateProjects.run()responsible for parsing and invokingProjectGenerator(...).write()only.Notes
Clean architecture lens:
GenerateProjectsis a delivery adapter, while the resolved generation request is the CLI application boundary. Extracting that boundary keeps domain models inproject-generatorunchanged while making CLI policy explicit and easier to test.Fixes #424
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