Skip to content

Add version catalog flag and interactive setup option for new projects#47

Open
StephenBrough wants to merge 1 commit intoktorio:mainfrom
StephenBrough:new-project-version-catalog
Open

Add version catalog flag and interactive setup option for new projects#47
StephenBrough wants to merge 1 commit intoktorio:mainfrom
StephenBrough:new-project-version-catalog

Conversation

@StephenBrough
Copy link

Added a --version-catalog flag to the new command. Also added a checkbox as part of the interactive setup.

Adding dependencies to an existing project with the version catalog appears to still work as well.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Walkthrough

This PR introduces a new VersionCatalog boolean feature across the application. It adds a command-line flag, CLI argument processing, interactive UI checkbox, state management, project generation parameter, and internationalization support for using Gradle version catalog dependency management.

Changes

Cohort / File(s) Summary
CLI Flag Processing
internal/app/cli/processing.go
Adds VersionCatalog Flag constant, bool field to Input struct, and entries to AllFlagsSpec and commandFlagSpec for the NewCommand. Updates ProcessArgs to parse and propagate the flag.
Command Execution
cmd/ktor/main.go, internal/app/cli/command/generate.go
Updates Generate function signatures to accept versionCatalog bool parameter (inserted after plugins argument) and passes it through to project generation.
Project Generation
internal/app/generate/project.go
Extends Project function signature with versionCatalog bool parameter; constructs versionCatalogValue payload and replaces hard-coded empty string for network.VersionCatalogBuildArg in BuildSystemArgs.
Internationalization
internal/app/i18n/messages.go, internal/app/i18n/bundle.en.go
Adds VersionCatalogCaption and VersionCatalogOptionDescr message constants and English translations.
Interactive UI — State & Drawing
internal/app/interactive/draw/state.go, internal/app/interactive/draw/tui.go
Introduces VersionCatalogCheckbox enum member to Element type; adds UI rendering for checkbox with label, styles, and layout positioning after location input. Note: NewState() initialization maps (CursorOffs, VisibleOffs, InputLens) may not include entries for the new checkbox.
Interactive UI — Event Handling & State
internal/app/interactive/entry.go, internal/app/interactive/model/state.go
Adds event handling for VersionCatalogCheckbox (space key toggles, Enter key toggles), restructures navigation logic to handle the checkbox without PluginsShown gating, and adds VersionCatalog bool field to Result struct. Propagates VersionCatalog value to generateProject result.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding a version catalog flag and interactive option for new projects, matching the core modifications across multiple files.
Description check ✅ Passed The description is directly related to the changeset, explaining the addition of the --version-catalog flag and interactive checkbox for new project creation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@internal/app/interactive/entry.go`:
- Around line 273-278: The Enter handler currently toggles mdl.VersionCatalog
and returns early inside the case for draw.VersionCatalogCheckbox, preventing
the later switch that sets PluginsShown and advances focus; remove the early
return in the Enter branch so that after flipping mdl.VersionCatalog execution
falls through to the subsequent switch (the same Enter handler handling
draw.Tabs) which will set PluginsShown and update drawState.ActiveElement to
advance focus.

Comment on lines 273 to +278
case key == tcell.KeyEnter && mod == tcell.ModNone:
if drawState.ActiveElement == draw.Tabs {
switch drawState.ActiveElement {
case draw.VersionCatalogCheckbox:
mdl.VersionCatalog = !mdl.VersionCatalog
return
case draw.Tabs:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Enter on the VersionCatalog checkbox doesn’t advance.

The early return means users can’t continue with Enter and must use Tab, which breaks the otherwise “Enter-to-advance” flow. If advancing is intended, drop the return to let the subsequent switch set PluginsShown and move focus.

🛠️ Suggested tweak
case draw.VersionCatalogCheckbox:
    mdl.VersionCatalog = !mdl.VersionCatalog
-   return
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case key == tcell.KeyEnter && mod == tcell.ModNone:
if drawState.ActiveElement == draw.Tabs {
switch drawState.ActiveElement {
case draw.VersionCatalogCheckbox:
mdl.VersionCatalog = !mdl.VersionCatalog
return
case draw.Tabs:
case key == tcell.KeyEnter && mod == tcell.ModNone:
switch drawState.ActiveElement {
case draw.VersionCatalogCheckbox:
mdl.VersionCatalog = !mdl.VersionCatalog
case draw.Tabs:
🤖 Prompt for AI Agents
In `@internal/app/interactive/entry.go` around lines 273 - 278, The Enter handler
currently toggles mdl.VersionCatalog and returns early inside the case for
draw.VersionCatalogCheckbox, preventing the later switch that sets PluginsShown
and advances focus; remove the early return in the Enter branch so that after
flipping mdl.VersionCatalog execution falls through to the subsequent switch
(the same Enter handler handling draw.Tabs) which will set PluginsShown and
update drawState.ActiveElement to advance focus.

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.

1 participant