mirror of
https://github.com/mgechev/revive.git
synced 2025-06-04 23:07:22 +02:00
Drop chalk
This commit is contained in:
parent
8f8a8b5587
commit
57a87dda1a
@ -4,9 +4,9 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/mgechev/revive/rule"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/ttacon/chalk"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -21,13 +21,13 @@ type CLIFormatter struct {
|
||||
}
|
||||
|
||||
func formatFailure(failure rule.Failure) []string {
|
||||
fString := chalk.Blue.Color(failure.Failure)
|
||||
fString := color.BlueString(failure.Failure)
|
||||
fTypeStr := string(failure.Type)
|
||||
fType := chalk.Red.Color(fTypeStr)
|
||||
fType := color.RedString(fTypeStr)
|
||||
lineColumn := failure.Position
|
||||
pos := chalk.Dim.TextStyle(fmt.Sprintf("(%d, %d)", lineColumn.Start.Line, lineColumn.Start.Column))
|
||||
pos := fmt.Sprintf("(%d, %d)", lineColumn.Start.Line, lineColumn.Start.Column)
|
||||
if failure.Type == rule.FailureTypeWarning {
|
||||
fType = chalk.Yellow.Color(fTypeStr)
|
||||
fType = color.YellowString(fTypeStr)
|
||||
}
|
||||
return []string{failure.GetFilename(), pos, fType, fString}
|
||||
}
|
||||
@ -68,18 +68,19 @@ func (f *CLIFormatter) Format(failures []rule.Failure) (string, error) {
|
||||
table.SetAutoWrapText(false)
|
||||
table.AppendBulk(val)
|
||||
table.Render()
|
||||
output += chalk.Dim.TextStyle(chalk.Underline.TextStyle(filename) + "\n")
|
||||
c := color.New(color.Underline)
|
||||
output += c.SprintfFunc()(filename + "\n")
|
||||
output += buf.String() + "\n"
|
||||
}
|
||||
|
||||
suffix := fmt.Sprintf(" %d %s (%d errors) (%d warnings)", total, ps, totalErrors, total-totalErrors)
|
||||
|
||||
if total > 0 && totalErrors > 0 {
|
||||
suffix = chalk.Red.Color("\n ✖" + suffix)
|
||||
suffix = color.RedString("\n ✖" + suffix)
|
||||
} else if total > 0 && totalErrors == 0 {
|
||||
suffix = chalk.Yellow.Color("\n ✖" + suffix)
|
||||
suffix = color.YellowString("\n ✖" + suffix)
|
||||
} else {
|
||||
suffix = chalk.Green.Color("\n" + suffix)
|
||||
suffix = color.GreenString("\n" + suffix)
|
||||
}
|
||||
return output + suffix, nil
|
||||
}
|
||||
|
10
glide.lock
generated
10
glide.lock
generated
@ -1,10 +1,10 @@
|
||||
hash: e7fa4d774614236f030e76f8adab9e29c97c0cfc9782e0cffb9c9df47be0e60e
|
||||
updated: 2017-08-27T19:03:09.172223776-07:00
|
||||
hash: 27a6def8732c04c5d65ba43db415d24c589f0553d576ec058b24d52f9eea6150
|
||||
updated: 2017-11-19T18:44:29.858067-08:00
|
||||
imports:
|
||||
- name: github.com/fatih/color
|
||||
version: 570b54cabe6b8eb0bc2dfce68d964677d63b5260
|
||||
- name: github.com/mattn/go-runewidth
|
||||
version: 9e777a8366cce605130a531d2cd6363d07ad7317
|
||||
- name: github.com/olekukonko/tablewriter
|
||||
version: be5337e7b39e64e5f91445ce7e721888dbab7387
|
||||
- name: github.com/ttacon/chalk
|
||||
version: 76b3c8b611dea8f83e49e9ce81fc2b189e0ef3d2
|
||||
version: a7a4c189eb47ed33ce7b35f2880070a0c82a67d4
|
||||
testImports: []
|
||||
|
@ -1,7 +1,7 @@
|
||||
package: github.com/mgechev/revive
|
||||
import:
|
||||
- package: github.com/ttacon/chalk
|
||||
version: ~0.1.0
|
||||
- package: github.com/olekukonko/tablewriter
|
||||
- package: github.com/mattn/go-runewidth
|
||||
version: ~0.0.2
|
||||
- package: github.com/fatih/color
|
||||
version: ~1.5.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user