diff --git a/README.md b/README.md index 9f6a62c..1c9f461 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Install goreporter (see above). ## Run it: ``` -$ goreporter -p [projectRelativePath] -r [reportPath] -e [exceptPackagesName] -f [json/html] {-t templatePathIfHtml} +$ goreporter -p [projectRelativePath] -r [reportPath] -e [exceptPackagesName] -f [json/html/text] {-t templatePathIfHtml} ``` - -p Must be a valid Golang project path. diff --git a/tools/report2text.go b/tools/report2text.go index bb6da2b..a74db5f 100644 --- a/tools/report2text.go +++ b/tools/report2text.go @@ -1,8 +1,8 @@ package tools import ( - "os" "encoding/json" + "os" "github.com/fatih/color" "github.com/wgliang/goreporter/engine" @@ -28,7 +28,7 @@ _/_/ _/ ` metricsHeaderTpl = `>> %s Linter %s find:` summaryHeaderTpl = ` %s: %s` - errorInfoTpl = ` %s at line %d` + errorInfoTpl = ` %s at line %d` ) // DisplayAsText will display the json data to console @@ -36,12 +36,17 @@ func DisplayAsText(jsonData []byte) { var structData engine.Reporter json.Unmarshal(jsonData, &structData) + var score float64 + for _, metric := range structData.Metrics { + score = score + metric.Percentage*metric.Weight + } + color.Magenta( - headerTpl, - structData.Project, - structData.Score, - structData.Grade, - structData.TimeStamp, + headerTpl, + structData.Project, + int(score), + structData.Grade, + structData.TimeStamp, structData.Issues, ) for _, metric := range structData.Metrics { @@ -62,4 +67,4 @@ func DisplayAsText(jsonData []byte) { } else { os.Exit(0) } -} \ No newline at end of file +}