Skip to content

fix: refactor cli generation options to a request object - #425

Merged
cdsap merged 1 commit into
mainfrom
issue/424-hermes-refactor-cli-generation-options-to-a-a1
Aug 27, 2026
Merged

fix: refactor cli generation options to a request object#425
cdsap merged 1 commit into
mainfrom
issue/424-hermes-refactor-cli-generation-options-to-a-a1

Conversation

@cdsap

@cdsap cdsap commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Summary

Problem

cli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/Main.kt mixes 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 in cli/src/test/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectsCliTest.kt already 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 parsed GenerateProjects options to that type. Move resolveVersions, resolveGradle, resolveProjectRootPath, project-name derivation, and Android-only feature validation behind that request-building boundary. Keep GenerateProjects.run() responsible for parsing and invoking ProjectGenerator(...).write() only.

Notes

Clean architecture lens: GenerateProjects is a delivery adapter, while the resolved generation request is the CLI application boundary. Extracting that boundary keeps domain models in project-generator unchanged while making CLI policy explicit and easier to test.

Fixes #424

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 0e1cd93 into main Aug 27, 2026
12 checks passed
@cdsap
cdsap deleted the issue/424-hermes-refactor-cli-generation-options-to-a-a1 branch August 27, 2026 20:24
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 CLI generation options to a request object

1 participant