Skip to content

split CLI into smaller parts#105

Merged
fmazmz merged 1 commit intomainfrom
refactor/cli-app
Jan 12, 2026
Merged

split CLI into smaller parts#105
fmazmz merged 1 commit intomainfrom
refactor/cli-app

Conversation

@fmazmz
Copy link
Copy Markdown
Member

@fmazmz fmazmz commented Jan 12, 2026

Summary by CodeRabbit

Release Notes

  • Refactor
    • Reorganized CLI application menu structure with enhanced navigation flows
    • Restructured authentication, account setup, and company management workflows
    • Improved input handling and session context management across operations
    • Consolidated invoice, client, and company user management into streamlined menus

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 12, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR restructures the CLI application by removing the legacy flat CliApp class and replacing it with a new modular org.example.cli package containing an orchestrator CliApp, infrastructure components (CliContext, InputHelper, ServiceContainer), and separate menu classes for authentication, account management, company setup, and CRUD operations.

Changes

Cohort / File(s) Summary
Core CLI Infrastructure
src/main/java/org/example/App.java, src/main/java/org/example/cli/CliApp.java, src/main/java/org/example/cli/CliContext.java, src/main/java/org/example/cli/InputHelper.java, src/main/java/org/example/cli/ServiceContainer.java
Migrated App.java to import new CliApp location (+3/-1); introduced CliApp as the main orchestrator coordinating banner display, auth/account/company setup flows, and main menu (+88); added CliContext for session state tracking (user/company context, login/selection predicates, +73); introduced InputHelper for centralized console I/O with confirmation prompts (+78); and ServiceContainer for dependency injection wiring repositories and services (+79)
Authentication & Account Management
src/main/java/org/example/cli/menu/AuthMenu.java, src/main/java/org/example/cli/menu/AccountMenu.java
AuthMenu handles login and registration flows with error handling for auth/validation/business exceptions and context updates (+92); AccountMenu provides account deletion with confirmation and session clearing (+59)
Company Management
src/main/java/org/example/cli/menu/CompanySetupMenu.java, src/main/java/org/example/cli/menu/CompanySettingsMenu.java, src/main/java/org/example/cli/menu/CompanyUserMenu.java
CompanySetupMenu manages company creation and selection with user association (+161); CompanySettingsMenu allows company detail updates and viewing with context synchronization (+107); CompanyUserMenu handles listing, adding, and removing company users with safeguards preventing self-removal (+136)
Client & Invoice Management
src/main/java/org/example/cli/menu/ClientMenu.java, src/main/java/org/example/cli/menu/InvoiceMenu.java, src/main/java/org/example/cli/menu/InvoiceItemMenu.java
ClientMenu provides full CRUD for clients with company-scoped filtering and entity selection (+219); InvoiceMenu manages invoices with client selection, status updates, and item delegation (+223); InvoiceItemMenu handles invoice item CRUD within invoice context (+219)
Main Navigation
src/main/java/org/example/cli/menu/MainMenu.java
Added MainMenu as central navigation hub with six options (clients, invoices, company users, settings, company switch, logout) and sub-menu delegation (+84)
Removed
src/main/java/org/example/CliApp.java
Deleted legacy monolithic CliApp containing all CLI logic (auth, menus, CRUD operations, -1203)

Sequence Diagram

sequenceDiagram
    participant User
    participant CliApp as CliApp<br/>(Orchestrator)
    participant AuthMenu
    participant AccountMenu
    participant CompanySetupMenu
    participant MainMenu
    participant Services

    User->>CliApp: start()
    CliApp->>CliApp: printBanner()
    
    loop Auth Loop
        CliApp->>AuthMenu: show()
        AuthMenu->>Services: authenticate/register
        Services-->>AuthMenu: success/error
        AuthMenu->>CliApp: return true/false
        break on success
        end
    end
    
    CliApp->>AccountMenu: show()
    AccountMenu->>Services: check account
    Services-->>AccountMenu: account data
    
    loop Company Setup Loop
        CliApp->>CompanySetupMenu: show()
        CompanySetupMenu->>Services: create/list companies
        Services-->>CompanySetupMenu: company list/created
        CompanySetupMenu->>CliApp: return true/false
        break on company selected
        end
    end
    
    loop Main Menu Loop
        CliApp->>MainMenu: show()
        MainMenu->>Services: CRUD operations
        Services-->>MainMenu: results
        MainMenu->>CliApp: continue/logout
        break on logout
        end
    end
    
    CliApp->>User: exit
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • PR #43: Refactors CliApp class with DTO updates and import changes, directly addressing the same CLI entrypoint being reorganized in this PR
  • PR #51: Augments CLI application functionality with invoice management integration, overlapping with invoice feature additions in this PR
  • PR #28: Introduces the original root-package CliApp that this PR removes and completely restructures into a modular org.example.cli package

Poem

🐰 Hops of joy, the CLI takes flight,
From monolith to menus, organized just right,
Auth, accounts, companies too—
Each menu neat, each flow shines through,
Refactored with care, the rabbit's delight!

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9fa5041 and 1923064.

📒 Files selected for processing (15)
  • src/main/java/org/example/App.java
  • src/main/java/org/example/CliApp.java
  • src/main/java/org/example/cli/CliApp.java
  • src/main/java/org/example/cli/CliContext.java
  • src/main/java/org/example/cli/InputHelper.java
  • src/main/java/org/example/cli/ServiceContainer.java
  • src/main/java/org/example/cli/menu/AccountMenu.java
  • src/main/java/org/example/cli/menu/AuthMenu.java
  • src/main/java/org/example/cli/menu/ClientMenu.java
  • src/main/java/org/example/cli/menu/CompanySettingsMenu.java
  • src/main/java/org/example/cli/menu/CompanySetupMenu.java
  • src/main/java/org/example/cli/menu/CompanyUserMenu.java
  • src/main/java/org/example/cli/menu/InvoiceItemMenu.java
  • src/main/java/org/example/cli/menu/InvoiceMenu.java
  • src/main/java/org/example/cli/menu/MainMenu.java

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.

@fmazmz fmazmz merged commit dd3b7c8 into main Jan 12, 2026
1 of 2 checks passed
@fmazmz fmazmz deleted the refactor/cli-app branch January 12, 2026 14:55
@coderabbitai coderabbitai Bot mentioned this pull request Jan 13, 2026
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