style(doctor): use ui library for consistent --server output styling
Use ui.RenderPassIcon, ui.RenderWarnIcon, ui.RenderFailIcon, etc. for consistent styling with the rest of the doctor command output. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
3bcbca41fe
commit
03400fbdbc
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/steveyegge/beads/cmd/bd/doctor"
|
"github.com/steveyegge/beads/cmd/bd/doctor"
|
||||||
"github.com/steveyegge/beads/internal/beads"
|
"github.com/steveyegge/beads/internal/beads"
|
||||||
"github.com/steveyegge/beads/internal/configfile"
|
"github.com/steveyegge/beads/internal/configfile"
|
||||||
|
"github.com/steveyegge/beads/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
// runCheckHealth runs lightweight health checks for git hooks.
|
// runCheckHealth runs lightweight health checks for git hooks.
|
||||||
@@ -128,31 +129,34 @@ func runServerHealth(path string) {
|
|||||||
// printServerHealthResult prints the server health check results
|
// printServerHealthResult prints the server health check results
|
||||||
func printServerHealthResult(result doctor.ServerHealthResult) {
|
func printServerHealthResult(result doctor.ServerHealthResult) {
|
||||||
var passCount, warnCount, failCount int
|
var passCount, warnCount, failCount int
|
||||||
|
var warnings []doctor.DoctorCheck
|
||||||
|
|
||||||
for _, check := range result.Checks {
|
for _, check := range result.Checks {
|
||||||
var statusIcon string
|
var statusIcon string
|
||||||
switch check.Status {
|
switch check.Status {
|
||||||
case statusOK:
|
case statusOK:
|
||||||
statusIcon = "✓"
|
statusIcon = ui.RenderPassIcon()
|
||||||
passCount++
|
passCount++
|
||||||
case statusWarning:
|
case statusWarning:
|
||||||
statusIcon = "⚠"
|
statusIcon = ui.RenderWarnIcon()
|
||||||
warnCount++
|
warnCount++
|
||||||
|
warnings = append(warnings, check)
|
||||||
case statusError:
|
case statusError:
|
||||||
statusIcon = "✗"
|
statusIcon = ui.RenderFailIcon()
|
||||||
failCount++
|
failCount++
|
||||||
|
warnings = append(warnings, check)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(" %s %s", statusIcon, check.Name)
|
fmt.Printf(" %s %s", statusIcon, check.Name)
|
||||||
if check.Message != "" {
|
if check.Message != "" {
|
||||||
fmt.Printf(" %s", check.Message)
|
fmt.Printf("%s", ui.RenderMuted(" "+check.Message))
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
if check.Detail != "" {
|
if check.Detail != "" {
|
||||||
// Indent detail lines
|
// Indent detail lines
|
||||||
for _, line := range strings.Split(check.Detail, "\n") {
|
for _, line := range strings.Split(check.Detail, "\n") {
|
||||||
fmt.Printf(" └─ %s\n", line)
|
fmt.Printf(" %s%s\n", ui.MutedStyle.Render(ui.TreeLast), ui.RenderMuted(line))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,27 +164,33 @@ func printServerHealthResult(result doctor.ServerHealthResult) {
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
// Summary line
|
// Summary line
|
||||||
fmt.Printf("─────────────────────────────────────────\n")
|
fmt.Println(ui.RenderSeparator())
|
||||||
fmt.Printf("✓ %d passed ⚠ %d warnings ✗ %d failed\n", passCount, warnCount, failCount)
|
summary := fmt.Sprintf("%s %d passed %s %d warnings %s %d failed",
|
||||||
|
ui.RenderPassIcon(), passCount,
|
||||||
|
ui.RenderWarnIcon(), warnCount,
|
||||||
|
ui.RenderFailIcon(), failCount,
|
||||||
|
)
|
||||||
|
fmt.Println(summary)
|
||||||
|
|
||||||
// Print fixes for any errors/warnings
|
// Print fixes for any errors/warnings
|
||||||
var fixes []doctor.DoctorCheck
|
if len(warnings) > 0 {
|
||||||
for _, check := range result.Checks {
|
|
||||||
if check.Fix != "" && (check.Status == statusError || check.Status == statusWarning) {
|
|
||||||
fixes = append(fixes, check)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(fixes) > 0 {
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("⚠ FIXES NEEDED")
|
fmt.Println(ui.RenderWarn(ui.IconWarn + " FIXES NEEDED"))
|
||||||
for i, check := range fixes {
|
for i, check := range warnings {
|
||||||
fmt.Printf(" %d. %s: %s\n", i+1, check.Name, check.Message)
|
if check.Fix == "" {
|
||||||
fmt.Printf(" └─ %s\n", check.Fix)
|
continue
|
||||||
|
}
|
||||||
|
line := fmt.Sprintf("%s: %s", check.Name, check.Message)
|
||||||
|
if check.Status == statusError {
|
||||||
|
fmt.Printf(" %s %s %s\n", ui.RenderFailIcon(), ui.RenderFail(fmt.Sprintf("%d.", i+1)), ui.RenderFail(line))
|
||||||
|
} else {
|
||||||
|
fmt.Printf(" %s %s %s\n", ui.RenderWarnIcon(), ui.RenderWarn(fmt.Sprintf("%d.", i+1)), line)
|
||||||
|
}
|
||||||
|
fmt.Printf(" %s%s\n", ui.MutedStyle.Render(ui.TreeLast), check.Fix)
|
||||||
}
|
}
|
||||||
} else if result.OverallOK {
|
} else if result.OverallOK {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("✓ All server health checks passed")
|
fmt.Printf("%s\n", ui.RenderPass("✓ All server health checks passed"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user