Skip to content

style(console): enhance banner and UI styling with bold formatting - #35

Merged
loadinglucian merged 4 commits into
mainfrom
refactor/server-helpers-extract-selection-logic
Oct 10, 2025
Merged

style(console): enhance banner and UI styling with bold formatting#35
loadinglucian merged 4 commits into
mainfrom
refactor/server-helpers-extract-selection-logic

Conversation

@loadinglucian

@loadinglucian loadinglucian commented Oct 10, 2025

Copy link
Copy Markdown
Owner
  • Add bold formatting to banner lines in SymfonyApp
  • Enhance h1() and hr() methods with bold styling
  • Improve visual hierarchy and readability of console output

Summary by CodeRabbit

  • New Features

    • Added interactive server selection when deleting, with graceful handling when no servers are available.
    • Unified, detailed server information display across add, list, and delete commands.
  • Style

    • Refreshed console banner with bold styling for improved readability.
    • Enhanced output formatting and headings with clearer labels and stronger color emphasis for server details.

- Add selectServer() method to handle server selection with empty inventory handling
- Rename displayServerInfo() to displayServerDeets() for consistency
- Update tests to reflect method name changes
- Simplify server display formatting
- Replace inline server selection logic with selectServer() method
- Use displayServerDeets() for consistent server information display
- Remove unused ServerDTO import
- Reduce code complexity by 56 lines
- Replace displayServerInfo() calls with displayServerDeets() in ServerAddCommand
- Replace displayServerInfo() calls with displayServerDeets() in ServerListCommand
- Maintain consistent method naming across all server commands
- Add bold formatting to banner lines in SymfonyApp
- Enhance h1() and hr() methods with bold styling
- Improve visual hierarchy and readability of console output
@coderabbitai

coderabbitai Bot commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Renames displayServerInfo to displayServerDeets across commands and tests, adds a selectServer helper to centralize server selection, refactors ServerDeleteCommand to use the new selection flow, and updates console/banner styling to use bold variants. No public API changes to commands; trait signatures updated.

Changes

Cohort / File(s) Summary
Server helper refactor
app/Traits/ServerHelpersTrait.php
Renamed displayServerInfo(ServerDTO, string) to displayServerDeets(ServerDTO) (removed color param); added selectServer(string $optionName = 'name', string $promptLabel = 'Select server:'): array; updated output formatting to labeled gray lines.
Server delete: selection-based flow
app/Console/Server/ServerDeleteCommand.php
Replaced manual name prompt and search with selectServer; early-exit on empty inventory; updated confirmations and messages to operate on the selected ServerDTO; switched to displayServerDeets.
Commands adopting method rename
app/Console/Server/ServerAddCommand.php, app/Console/Server/ServerListCommand.php
Switched calls from displayServerInfo(...) to displayServerDeets(...); no other logic changes.
Console styling updates
app/Traits/ConsoleOutputTrait.php, app/SymfonyApp.php
Made headings/separators and banner lines bold; adjusted color tokens (e.g., cyan;options=bold) and spacing/indentation; no control-flow changes.
Tests adjusted to new helper
tests/Fixtures/TestConsoleCommand.php, tests/Unit/Traits/ServerHelpersTraitTest.php
Updated references and method names from displayServerInfo to displayServerDeets; no test logic changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant D as ServerDeleteCommand
  participant H as ServerHelpersTrait
  participant I as Inventory
  participant O as Console Output

  U->>D: run server:delete
  D->>H: selectServer()
  H->>I: getAllServers()
  alt No servers
    H-->>D: { server: null, exit_code: SUCCESS }
    D->>O: warn "No servers" + guidance
    D-->>U: SUCCESS
  else Servers exist
    H->>U: prompt "Select server"
    U-->>H: selection
    H->>I: findByName(selection)
    alt Found
      H-->>D: { server: ServerDTO, exit_code: SUCCESS }
      D->>O: displayServerDeets(server)
      D->>U: confirm "Delete?"
      alt Yes
        D->>I: delete(server.name)
        D->>O: info "Deleted"
        D-->>U: SUCCESS
      else No
        D->>O: note "Cancelled"
        D-->>U: SUCCESS
      end
    else Not found
      H-->>D: { server: null, exit_code: FAILURE }
      D->>O: error "Server not found"
      D-->>U: FAILURE
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • bigpixelrocket/deployer-php#27 — Introduced server command helpers and displayServerInfo; directly precedes this rename to displayServerDeets and selection flow usage.
  • bigpixelrocket/deployer-php#26 — Adjusts ConsoleOutputTrait formatting; overlaps with the bold styling updates here.
  • bigpixelrocket/deployer-php#20 — Changes SymfonyApp banner rendering; related to the banner styling modifications in this PR.

Poem

Thump-thump goes my reviewy feet,
New deets gleam bold and neat.
I hop, I pick, I safely select,
Delete with care—then genuflect.
In cyan hues, my console sings,
A tidy warren of server things. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely summarizes the primary change to console styling by adding bold formatting to the banner and UI elements, directly reflecting the main modifications introduced in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/server-helpers-extract-selection-logic

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/Traits/ServerHelpersTrait.php (1)

36-89: LGTM! Well-structured server selection helper.

The selectServer method effectively centralizes server selection logic, handling edge cases appropriately:

  • Empty inventory returns SUCCESS (allows graceful exit)
  • Not found returns FAILURE (indicates error)
  • Clear array shape return type for static analysis

The linear search (lines 74-80) is acceptable for small server inventories typical in deployment scenarios.

Optionally, the server lookup could use array_filter for a more functional style:

$server = array_values(array_filter($allServers, fn(ServerDTO $s) => $s->name === $name))[0] ?? null;

However, the current foreach approach is equally clear and more readable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6deaf3a and 2ead14d.

📒 Files selected for processing (8)
  • app/Console/Server/ServerAddCommand.php (1 hunks)
  • app/Console/Server/ServerDeleteCommand.php (2 hunks)
  • app/Console/Server/ServerListCommand.php (1 hunks)
  • app/SymfonyApp.php (1 hunks)
  • app/Traits/ConsoleOutputTrait.php (2 hunks)
  • app/Traits/ServerHelpersTrait.php (2 hunks)
  • tests/Fixtures/TestConsoleCommand.php (1 hunks)
  • tests/Unit/Traits/ServerHelpersTraitTest.php (3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.php

📄 CodeRabbit inference engine (.cursor/rules/00-main.mdc)

**/*.php: Eliminate single-use private methods by inlining them directly
Cache expensive computed values by initializing them in the constructor instead of recomputing
Prefer direct property access over method calls when appropriate to avoid call overhead
Organize code into comment-separated sections; prefer alphabetical ordering when it does not conflict with logical grouping

**/*.php: Adhere to PSR-12 coding style in all PHP files
Declare strict_types=1 at the top of every PHP file
Prefer PHP 8.x features (union types, match, attributes, readonly) where appropriate
Always import classes with use statements; avoid fully qualified class names in code bodies
All methods must declare explicit return types; use proper generics in types/docblocks (e.g., Collection<int, User>)
Use dependency injection instead of manually resolving or instantiating classes
Prefer Symfony component classes (e.g., Filesystem, Process) over native PHP functions for testability
All object creation must use $container->build(ClassName::class) instead of new, except for value objects/DTOs/pure data structures
In production code, access the Container via constructor injection, not via static/global access
Add minimal DocBlock comments with descriptions, parameters, and return types for classes and functions
Use comments as visual separators for sections/subsections with a single newline between header, subheader, and paragraph; avoid obvious or stale comments
Run rector on changed PHP files before completing a task
Run pint on changed PHP files to fix code style before completing a task

Files:

  • app/Console/Server/ServerAddCommand.php
  • app/Console/Server/ServerDeleteCommand.php
  • app/Traits/ConsoleOutputTrait.php
  • app/Traits/ServerHelpersTrait.php
  • app/SymfonyApp.php
  • app/Console/Server/ServerListCommand.php
  • tests/Unit/Traits/ServerHelpersTraitTest.php
  • tests/Fixtures/TestConsoleCommand.php
**/*Command.php

📄 CodeRabbit inference engine (.cursor/rules/01-architecture.mdc)

**/*Command.php: Commands handle user interaction (input/output) and orchestrate services
Commands must not contain business logic; delegate business logic to Services
Commands must not duplicate orchestration logic; extract shared orchestration to Services
Commands should not invoke other commands (no proxy commands)
Use SymfonyStyle consistently for all user-facing console output

Files:

  • app/Console/Server/ServerAddCommand.php
  • app/Console/Server/ServerDeleteCommand.php
  • app/Console/Server/ServerListCommand.php
  • tests/Fixtures/TestConsoleCommand.php
app/Traits/ConsoleOutputTrait.php

📄 CodeRabbit inference engine (.cursor/rules/03-commands.mdc)

Add new output/formatting methods to ConsoleOutputTrait rather than calling SymfonyStyle directly

Files:

  • app/Traits/ConsoleOutputTrait.php
{tests/**,test/**,**/*@(Test|Spec).php}

📄 CodeRabbit inference engine (.cursor/rules/00-main.mdc)

Do not run or edit tests unless explicitly instructed

Files:

  • tests/Unit/Traits/ServerHelpersTraitTest.php
  • tests/Fixtures/TestConsoleCommand.php
tests/**/*.php

📄 CodeRabbit inference engine (.cursor/rules/01-architecture.mdc)

tests/**/*.php: In tests, direct Container instantiation and bind() for mocks is allowed and encouraged for isolation
Do not run PHPStan on test files; tests are excluded from static analysis

tests/**/*.php: Unit tests must instantiate services manually (no DI container)
Command/integration tests must use mockCommandContainer() for building commands and overriding services
Only use container auto-wiring in tests to verify DI configuration or multi-service integration (edge cases)
Keep test files under 1.8x the size of the source they test (without sacrificing readability)
Test core business logic; avoid testing the framework itself
Prefer dataset-driven testing using ->with([...]) for multiple scenarios
Consolidate related assertions (e.g., expect($x)->toBe(...)->and($y)->toBe(...))
Mock only external dependencies; keep unit tests isolated from filesystem/HTTP/processes
Avoid performance tests unless performance is the primary concern
Use the AAA pattern in tests (Arrange, Act, Assert; optional Cleanup)
In exception tests, use a combined // ACT & ASSERT step when the act triggers the assertion
Organize tests with describe() blocks, beforeEach() setup, and shared helpers/traits for DRY
Forbidden assertions in tests: type-only or generic checks (e.g., toBeInstanceOf, toBeArray, not->toBeNull, expect(true)->toBeTrue) and sleep(...); prefer time mocking
Preferred assertions: assert observable behavior and interactions (e.g., domain values, validator outcomes, mock expectations)
Unit tests: mock all external dependencies, test single units in isolation, and complete in milliseconds
Integration tests: use real file operations and external processes; cover CLI commands and full workflows
Do not require PHPStan compliance in tests; avoid excessive phpdoc solely to satisfy types in tests

Files:

  • tests/Unit/Traits/ServerHelpersTraitTest.php
  • tests/Fixtures/TestConsoleCommand.php
🧠 Learnings (1)
📚 Learning: 2025-10-04T12:08:48.865Z
Learnt from: CR
PR: bigpixelrocket/deployer-php#0
File: .cursor/rules/03-commands.mdc:0-0
Timestamp: 2025-10-04T12:08:48.865Z
Learning: Applies to app/Traits/ConsoleOutputTrait.php : Add new output/formatting methods to ConsoleOutputTrait rather than calling SymfonyStyle directly

Applied to files:

  • app/Traits/ConsoleOutputTrait.php
🧬 Code graph analysis (6)
app/Console/Server/ServerAddCommand.php (1)
app/Traits/ServerHelpersTrait.php (1)
  • displayServerDeets (24-34)
app/Console/Server/ServerDeleteCommand.php (2)
app/Traits/ServerHelpersTrait.php (2)
  • selectServer (41-89)
  • displayServerDeets (24-34)
app/Traits/ConsoleOutputTrait.php (2)
  • writeln (23-29)
  • showCommandHint (102-138)
app/Traits/ServerHelpersTrait.php (4)
app/DTOs/ServerDTO.php (1)
  • ServerDTO (7-17)
app/Traits/ConsoleOutputTrait.php (3)
  • writeln (23-29)
  • warning (54-57)
  • error (62-65)
app/Repositories/ServerRepository.php (1)
  • all (83-93)
app/Traits/ConsoleInputTrait.php (2)
  • getOptionOrPrompt (50-69)
  • promptSelect (183-199)
app/Console/Server/ServerListCommand.php (1)
app/Traits/ServerHelpersTrait.php (1)
  • displayServerDeets (24-34)
tests/Unit/Traits/ServerHelpersTraitTest.php (1)
tests/Fixtures/TestConsoleCommand.php (1)
  • setTestMethod (46-50)
tests/Fixtures/TestConsoleCommand.php (1)
app/Traits/ServerHelpersTrait.php (1)
  • displayServerDeets (24-34)
🔇 Additional comments (11)
tests/Unit/Traits/ServerHelpersTraitTest.php (1)

20-20: LGTM! Test references updated correctly.

The test method calls have been updated to reference displayServerDeets consistently, aligning with the renamed trait method. Test logic and assertions remain unchanged.

Also applies to: 25-25, 54-54, 71-71

app/Console/Server/ServerAddCommand.php (1)

132-132: LGTM! Method call updated correctly.

The call to displayServerDeets aligns with the renamed trait method. Server display logic remains unchanged.

app/Traits/ConsoleOutputTrait.php (2)

77-77: LGTM! Enhanced heading styling with bold formatting.

The bold cyan styling improves visual hierarchy for h1 headings, consistent with the PR's styling objectives.


88-88: LGTM! Enhanced separator styling with bold formatting.

The bold styling across all color segments creates a more prominent visual separator, improving console output readability.

app/Console/Server/ServerListCommand.php (1)

50-50: LGTM! Method call updated correctly.

The display method call has been updated to use displayServerDeets, consistent with the trait refactor.

tests/Fixtures/TestConsoleCommand.php (1)

73-73: LGTM! Test fixture updated correctly.

The match case has been updated to dispatch to displayServerDeets, maintaining test fixture functionality with the renamed method.

app/SymfonyApp.php (1)

97-103: LGTM! Enhanced banner styling with bold formatting.

The banner now uses bold formatting across all elements, creating a more prominent and visually appealing application header. The changes are purely cosmetic and align with the PR's styling objectives.

app/Console/Server/ServerDeleteCommand.php (2)

49-58: LGTM! Excellent refactor using centralized server selection.

The refactor to use selectServer() improves code maintainability by centralizing server selection logic. The object-oriented flow around the selected server is cleaner and more consistent with the command's intent.


82-84: LGTM! Consistent use of server object properties.

Using $server->name directly from the selected server object is appropriate and maintains consistency with the refactored selection flow.

Also applies to: 91-91

app/Traits/ServerHelpersTrait.php (2)

10-10: LGTM! Import added for Command constants.

The import is necessary for using Command::SUCCESS and Command::FAILURE constants in the selectServer method.


22-34: LGTM! Improved method naming and simplified output formatting.

The rename to displayServerDeets better conveys the method's purpose, and removing the unused color parameter simplifies the interface. The consistent gray formatting with labeled fields improves readability.

@loadinglucian
loadinglucian merged commit 0e28748 into main Oct 10, 2025
5 checks passed
@loadinglucian
loadinglucian deleted the refactor/server-helpers-extract-selection-logic branch October 10, 2025 22:05
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