Skip to content

Commit

Permalink
Merge pull request #209 from gonvenience/fix/linter-finding
Browse files Browse the repository at this point in the history
Fix linter finding with constant format
  • Loading branch information
HeavyWombat authored Jan 7, 2025
2 parents eeecd0d + 3afe031 commit 2a19f16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewOutputProcessor(useIndentLines bool, boldKeys bool, colorSchema *map[str
}
}

// Deprecated: Use colorizef instead
// TODO Change signature to swap into the right order, color first, text second
func (p *OutputProcessor) colorize(text string, colorName string) string {
if p.colorSchema != nil {
if value, ok := (*p.colorSchema)[colorName]; ok {
Expand All @@ -93,18 +93,11 @@ func (p *OutputProcessor) colorize(text string, colorName string) string {
}

func (p *OutputProcessor) colorizef(colorName string, format string, a ...interface{}) string {
var text = format
if len(a) > 0 {
text = fmt.Sprintf(format, a...)
return p.colorize(fmt.Sprintf(format, a...), colorName)
}

if p.colorSchema != nil {
if value, ok := (*p.colorSchema)[colorName]; ok {
return bunt.Style(text, bunt.Foreground(value))
}
}

return text
return p.colorize(format, colorName)
}

func (p *OutputProcessor) determineColorByType(obj interface{}) string {
Expand Down
2 changes: 1 addition & 1 deletion output_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (p *OutputProcessor) neatYAMLofNode(prefix string, skipIndentOnFirstLine bo
if needsQuotes(node) {
fmt.Fprint(p.out, p.colorizef(colorName, `"%s"`, node.Value))
} else {
fmt.Fprint(p.out, p.colorizef(colorName, node.Value))
fmt.Fprint(p.out, p.colorize(node.Value, colorName))
}

default:
Expand Down

0 comments on commit 2a19f16

Please sign in to comment.