Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Add json output for calculated metric results
Browse files Browse the repository at this point in the history
  • Loading branch information
Burak Olgun committed Sep 14, 2020
1 parent 501184e commit 45a3523
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion cmd/run_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
. "four-key/models"
"four-key/settings"
"four-key/template"
"github.com/spf13/cobra"
"os"
"path"
"strconv"
"strings"
"time"

"github.com/spf13/cobra"
)

var runCommand = &cobra.Command{
Expand Down Expand Up @@ -284,12 +285,19 @@ func createChartItems(metrics []TagMetricDto) ChartItems {

func generateOutput(dir string, items ChartItems, results FourKeyMetricResultDto, outputSource string, open bool) error {
var h *os.File
var j *os.File
h, err := os.Create(path.Join(outputSource, results.TeamName, dir, "index.html"))

if err != nil {
return err
}

j, err = os.Create(path.Join(outputSource, results.TeamName, dir, "metrics.json"))

if err != nil {
return err
}

html, err := createHtml(results, items)

if err != nil {
Expand All @@ -308,6 +316,20 @@ func generateOutput(dir string, items ChartItems, results FourKeyMetricResultDto
return err
}

resultsJson, err := json.Marshal(results)

_, err = j.WriteString(string(resultsJson))

if err != nil {
err = j.Close()

if err != nil {
return err
}

return err
}

if open {
err := commander.Open(outputSource)

Expand Down

0 comments on commit 45a3523

Please sign in to comment.