doctor: collapse healthy output to one line, add --verbose
A healthy host triggered ~20 PASS rows with details — too noisy for the common case. Default now prints only fail/warn rows plus a summary footer; an all-pass run collapses to a single line. Pass --verbose / -v for the full per-check output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
09a3ef812f
commit
9b5cbed32d
4 changed files with 142 additions and 7 deletions
|
|
@ -272,9 +272,34 @@ func printKernelCatalogTable(out anyWriter, entries []api.KernelCatalogEntry) er
|
|||
|
||||
// -- doctor printer -------------------------------------------------
|
||||
|
||||
func printDoctorReport(out anyWriter, report system.Report) error {
|
||||
func printDoctorReport(out anyWriter, report system.Report, verbose bool) error {
|
||||
colorWriter, _ := out.(io.Writer)
|
||||
|
||||
var passes, warns, fails int
|
||||
for _, c := range report.Checks {
|
||||
switch c.Status {
|
||||
case system.CheckStatusPass:
|
||||
passes++
|
||||
case system.CheckStatusWarn:
|
||||
warns++
|
||||
case system.CheckStatusFail:
|
||||
fails++
|
||||
}
|
||||
}
|
||||
|
||||
if !verbose && warns == 0 && fails == 0 {
|
||||
msg := fmt.Sprintf("all %d checks passed", passes)
|
||||
if colorWriter != nil {
|
||||
msg = style.Pass(colorWriter, msg)
|
||||
}
|
||||
_, err := fmt.Fprintln(out, msg)
|
||||
return err
|
||||
}
|
||||
|
||||
for _, check := range report.Checks {
|
||||
if !verbose && check.Status == system.CheckStatusPass {
|
||||
continue
|
||||
}
|
||||
status := strings.ToUpper(string(check.Status))
|
||||
if colorWriter != nil {
|
||||
switch check.Status {
|
||||
|
|
@ -295,5 +320,19 @@ func printDoctorReport(out anyWriter, report system.Report) error {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !verbose {
|
||||
if _, err := fmt.Fprintf(out, "\n%d passed, %s, %s\n", passes, pluralCount(warns, "warning"), pluralCount(fails, "failure")); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func pluralCount(n int, word string) string {
|
||||
if n == 1 {
|
||||
return fmt.Sprintf("%d %s", n, word)
|
||||
}
|
||||
return fmt.Sprintf("%d %ss", n, word)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue