feat(cli): colorized, columnized text output with line:col locations
Replace the per-line fmt.Println loop with writeTextFindings() in cmd/glint/output.go. The new renderer: - Aligns all findings into four space-separated columns: location, rule ID, severity, message — widths computed from the full finding set so all lines are flush - Colors severity words when stdout is a TTY and NO_COLOR is not set: red+bold for "error", orange+bold for "warning"; location dimmed; rule ID bold - Formats location as file:line:col when column is known, file:line otherwise, falling back to just file To populate column numbers, add Column int to model.Job (set from keyNode.Column in the YAML parser) and Finding.Column (set during the checkJob source-location attachment pass and in the ten cross-job check sites that explicitly set Line: job.Line). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,15 +22,19 @@ type Finding struct {
|
||||
Job string // empty for pipeline-level findings
|
||||
File string // source file where the finding originates
|
||||
Line int // line number in File (0 = unknown)
|
||||
Column int // column number in File (0 = unknown; 1-indexed)
|
||||
Message string
|
||||
}
|
||||
|
||||
func (f Finding) String() string {
|
||||
var loc string
|
||||
if f.File != "" {
|
||||
if f.Line > 0 {
|
||||
switch {
|
||||
case f.Line > 0 && f.Column > 0:
|
||||
loc = fmt.Sprintf("%s:%d:%d: ", f.File, f.Line, f.Column)
|
||||
case f.Line > 0:
|
||||
loc = fmt.Sprintf("%s:%d: ", f.File, f.Line)
|
||||
} else {
|
||||
default:
|
||||
loc = fmt.Sprintf("%s: ", f.File)
|
||||
}
|
||||
}
|
||||
@@ -225,6 +229,7 @@ func checkJob(name string, job model.Job, stageSet map[string]bool) []Finding {
|
||||
if findings[i].Job != "" && findings[i].File == "" {
|
||||
findings[i].File = job.File
|
||||
findings[i].Line = job.Line
|
||||
findings[i].Column = job.Column
|
||||
}
|
||||
}
|
||||
return findings
|
||||
|
||||
Reference in New Issue
Block a user