Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 7 additions & 23 deletions blink/internal/reporter/reporter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package reporter reproduces ECS's console output: numbered file-diff blocks
// with "Applied checkers" listings, wrapped diffs, and Symfony-style
// success/warning status blocks.
// with "Applied checkers" listings, wrapped diffs, and single-line
// success/warning status lines.
package reporter

import (
Expand Down Expand Up @@ -158,22 +158,13 @@ func (f formatter) listing(items []string) {
f.newLine(1)
}

// success / warning render Symfony-style padded, colored blocks.
func (f formatter) success(msg string) { f.block("[OK]", msg, 30, 42) }
func (f formatter) warning(msg string) { f.block("[WARNING]", msg, 30, 43) }
// success / warning render ECS's single-line green/yellow status line.
func (f formatter) success(msg string) { f.statusLine("[OK]", msg, 32) }
func (f formatter) warning(msg string) { f.statusLine("[WARNING]", msg, 33) }

func (f formatter) block(tag, msg string, fg, bg int) {
f.newLine(1)
pad := func(s string) string {
if len([]rune(s)) < f.width {
s += strings.Repeat(" ", f.width-len([]rune(s)))
}
return f.bg(s, fg, bg)
}
f.writeln(pad(""))
f.writeln(pad(" " + tag + " " + msg))
f.writeln(pad(""))
func (f formatter) statusLine(tag, msg string, color int) {
f.newLine(1)
f.writeln(f.fg(" "+tag+" "+msg, color))
}

func (f formatter) newLine(n int) {
Expand All @@ -192,13 +183,6 @@ func (f formatter) fg(s string, code int) string {
return fmt.Sprintf("\x1b[%dm%s\x1b[39m", code, s)
}

func (f formatter) bg(s string, fg, bg int) string {
if !f.color {
return s
}
return fmt.Sprintf("\x1b[%d;%dm%s\x1b[39;49m", fg, bg, s)
}

func (f formatter) comment(s string) string { return f.fg(s, 33) } // yellow
func (f formatter) grey(s string) string { return f.fg(s, 90) } // bright black, matches PHP
func (f formatter) bold(s string) string {
Expand Down
Loading