diff --git a/cmd/php/php.go b/cmd/php/php.go index 5f2a66ce..f76bd40d 100644 --- a/cmd/php/php.go +++ b/cmd/php/php.go @@ -15,66 +15,36 @@ var ( linkStyle = shared.LinkStyle ) -// Service colors for log output +// Service colors for log output (domain-specific, keep local) var ( - phpFrankenPHPStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6366f1")) // indigo-500 - - phpViteStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#eab308")) // yellow-500 - - phpHorizonStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f97316")) // orange-500 - - phpReverbStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#8b5cf6")) // violet-500 - - phpRedisStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#ef4444")) // red-500 - - phpStatusRunning = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#22c55e")). // green-500 - Bold(true) - - phpStatusStopped = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6b7280")) // gray-500 - - phpStatusError = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#ef4444")). // red-500 - Bold(true) + phpFrankenPHPStyle = lipgloss.NewStyle().Foreground(shared.ColourIndigo500) + phpViteStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#eab308")) // yellow-500 + phpHorizonStyle = lipgloss.NewStyle().Foreground(shared.ColourOrange500) + phpReverbStyle = lipgloss.NewStyle().Foreground(shared.ColourViolet500) + phpRedisStyle = lipgloss.NewStyle().Foreground(shared.ColourRed500) ) -// QA command styles +// Status styles (from shared) var ( - phpQAPassedStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#22c55e")). // green-500 - Bold(true) + phpStatusRunning = shared.SuccessStyle + phpStatusStopped = shared.StatusPendingStyle + phpStatusError = shared.ErrorStyle +) - phpQAFailedStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#ef4444")). // red-500 - Bold(true) +// QA command styles (from shared) +var ( + phpQAPassedStyle = shared.SuccessStyle + phpQAFailedStyle = shared.ErrorStyle + phpQAWarningStyle = shared.WarningStyle + phpQAStageStyle = lipgloss.NewStyle().Bold(true).Foreground(shared.ColourIndigo500) +) - phpQAWarningStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f59e0b")). // amber-500 - Bold(true) - - phpQAStageStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6366f1")). // indigo-500 - Bold(true) - - phpSecurityCriticalStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#ef4444")). // red-500 - Bold(true) - - phpSecurityHighStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f97316")). // orange-500 - Bold(true) - - phpSecurityMediumStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f59e0b")) // amber-500 - - phpSecurityLowStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6b7280")) // gray-500 +// Security severity styles (from shared) +var ( + phpSecurityCriticalStyle = shared.SeverityCriticalStyle + phpSecurityHighStyle = shared.SeverityHighStyle + phpSecurityMediumStyle = shared.SeverityMediumStyle + phpSecurityLowStyle = shared.SeverityLowStyle ) // AddPHPCommands adds PHP/Laravel development commands. diff --git a/cmd/shared/styles.go b/cmd/shared/styles.go index 4c0fffe8..9470bc07 100644 --- a/cmd/shared/styles.go +++ b/cmd/shared/styles.go @@ -192,6 +192,54 @@ var ( StatusWarningStyle = lipgloss.NewStyle().Foreground(ColourAmber500) ) +// ───────────────────────────────────────────────────────────────────────────── +// Coverage Styles (for test/code coverage display) +// ───────────────────────────────────────────────────────────────────────────── + +var ( + // CoverageHighStyle for good coverage (80%+). + CoverageHighStyle = lipgloss.NewStyle().Foreground(ColourGreen500) + + // CoverageMedStyle for moderate coverage (50-79%). + CoverageMedStyle = lipgloss.NewStyle().Foreground(ColourAmber500) + + // CoverageLowStyle for low coverage (<50%). + CoverageLowStyle = lipgloss.NewStyle().Foreground(ColourRed500) +) + +// ───────────────────────────────────────────────────────────────────────────── +// Priority Styles (for task/issue priority levels) +// ───────────────────────────────────────────────────────────────────────────── + +var ( + // PriorityHighStyle for high/critical priority (red, bold). + PriorityHighStyle = lipgloss.NewStyle().Bold(true).Foreground(ColourRed500) + + // PriorityMediumStyle for medium priority (amber). + PriorityMediumStyle = lipgloss.NewStyle().Foreground(ColourAmber500) + + // PriorityLowStyle for low priority (green). + PriorityLowStyle = lipgloss.NewStyle().Foreground(ColourGreen500) +) + +// ───────────────────────────────────────────────────────────────────────────── +// Severity Styles (for security/QA severity levels) +// ───────────────────────────────────────────────────────────────────────────── + +var ( + // SeverityCriticalStyle for critical issues (red, bold). + SeverityCriticalStyle = lipgloss.NewStyle().Bold(true).Foreground(ColourRed500) + + // SeverityHighStyle for high severity issues (orange, bold). + SeverityHighStyle = lipgloss.NewStyle().Bold(true).Foreground(ColourOrange500) + + // SeverityMediumStyle for medium severity issues (amber). + SeverityMediumStyle = lipgloss.NewStyle().Foreground(ColourAmber500) + + // SeverityLowStyle for low severity issues (gray). + SeverityLowStyle = lipgloss.NewStyle().Foreground(ColourGray500) +) + // ───────────────────────────────────────────────────────────────────────────── // Box Styles (for bordered content) // ───────────────────────────────────────────────────────────────────────────── @@ -351,6 +399,61 @@ func Number(n int) string { return NumberStyle.Render(fmt.Sprintf("%d", n)) } +// FormatCoverage formats a coverage percentage with colour based on thresholds. +// High (green) >= 80%, Medium (amber) >= 50%, Low (red) < 50%. +func FormatCoverage(percent float64) string { + var style lipgloss.Style + switch { + case percent >= 80: + style = CoverageHighStyle + case percent >= 50: + style = CoverageMedStyle + default: + style = CoverageLowStyle + } + return style.Render(fmt.Sprintf("%.1f%%", percent)) +} + +// FormatCoverageCustom formats coverage with custom thresholds. +func FormatCoverageCustom(percent, highThreshold, medThreshold float64) string { + var style lipgloss.Style + switch { + case percent >= highThreshold: + style = CoverageHighStyle + case percent >= medThreshold: + style = CoverageMedStyle + default: + style = CoverageLowStyle + } + return style.Render(fmt.Sprintf("%.1f%%", percent)) +} + +// FormatSeverity returns styled text for a severity level. +func FormatSeverity(level string) string { + switch strings.ToLower(level) { + case "critical": + return SeverityCriticalStyle.Render(level) + case "high": + return SeverityHighStyle.Render(level) + case "medium", "med": + return SeverityMediumStyle.Render(level) + default: + return SeverityLowStyle.Render(level) + } +} + +// FormatPriority returns styled text for a priority level. +func FormatPriority(level string) string { + switch strings.ToLower(level) { + case "high", "critical", "urgent": + return PriorityHighStyle.Render(level) + case "medium", "med", "normal": + return PriorityMediumStyle.Render(level) + default: + return PriorityLowStyle.Render(level) + } +} + // ───────────────────────────────────────────────────────────────────────────── // Table Helpers // ───────────────────────────────────────────────────────────────────────────── diff --git a/cmd/test/test.go b/cmd/test/test.go index 89e51055..ca5f77af 100644 --- a/cmd/test/test.go +++ b/cmd/test/test.go @@ -4,30 +4,20 @@ package testcmd import ( - "github.com/charmbracelet/lipgloss" "github.com/host-uk/core/cmd/shared" "github.com/spf13/cobra" ) // Style aliases from shared var ( - testHeaderStyle = shared.RepoNameStyle - testPassStyle = shared.SuccessStyle - testFailStyle = shared.ErrorStyle - testSkipStyle = shared.WarningStyle - testDimStyle = shared.DimStyle -) - -// Coverage-specific styles -var ( - testCovHighStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#22c55e")) // green-500 - - testCovMedStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f59e0b")) // amber-500 - - testCovLowStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#ef4444")) // red-500 + testHeaderStyle = shared.RepoNameStyle + testPassStyle = shared.SuccessStyle + testFailStyle = shared.ErrorStyle + testSkipStyle = shared.WarningStyle + testDimStyle = shared.DimStyle + testCovHighStyle = shared.CoverageHighStyle + testCovMedStyle = shared.CoverageMedStyle + testCovLowStyle = shared.CoverageLowStyle ) // Flag variables for test command diff --git a/cmd/test/test_output.go b/cmd/test/test_output.go index e61de078..41b9722b 100644 --- a/cmd/test/test_output.go +++ b/cmd/test/test_output.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/charmbracelet/lipgloss" + "github.com/host-uk/core/cmd/shared" ) type packageCoverage struct { @@ -151,16 +151,7 @@ func printCoverageSummary(results testResults) { } func formatCoverage(cov float64) string { - var style lipgloss.Style - switch { - case cov >= 80: - style = testCovHighStyle - case cov >= 50: - style = testCovMedStyle - default: - style = testCovLowStyle - } - return style.Render(fmt.Sprintf("%.1f%%", cov)) + return shared.FormatCoverage(cov) } func shortenPackageName(name string) string {