Modify output formats

This commit is contained in:
Miguel de la Cruz 2020-09-24 14:16:51 +02:00
parent 82dc46f787
commit e2597d9791
2 changed files with 11 additions and 6 deletions

View file

@ -4,7 +4,9 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"strings" "strings"
"text/tabwriter"
"text/template" "text/template"
"os"
"github.com/fatih/color" "github.com/fatih/color"
) )
@ -71,11 +73,13 @@ func (c *Campaign) PrintStatus() {
} }
fmt.Printf("Current campaign for %s with summary\n%s\n\n", color.GreenString(c.Github.Repo), color.CyanString(c.Summary)) fmt.Printf("Current campaign for %s with summary\n%s\n\n", color.GreenString(c.Github.Repo), color.CyanString(c.Summary))
fmt.Printf("\t%d\ttotal tickets\n", totalTickets) w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', tabwriter.AlignRight)
fmt.Printf("\t%d/%d\tpublished in Jira\n", totalPublishedJira, totalTickets) fmt.Fprintf(w, " %d\ttotal tickets\t\n", totalTickets)
fmt.Printf("\t%d/%d\tpublished in Github\n", totalPublishedGithub, totalPublishedJira) fmt.Fprintf(w, " %d\tpublished in Jira\t\n", totalPublishedJira)
fmt.Printf("\t%d/%d\tassigned\n", totalAssigned, totalPublishedGithub) fmt.Fprintf(w, " %d\tpublished in Github\t\n", totalPublishedGithub)
fmt.Printf("\t%d/%d\tclosed\n\n", totalClosed, totalPublishedGithub) fmt.Fprintf(w, " %d\tassigned\t\n", totalAssigned)
fmt.Fprintf(w, " %d\tclosed\t\n\n", totalClosed)
w.Flush()
} }
func (c *Campaign) AddTickets(tickets []*Ticket, fileOnly bool) { func (c *Campaign) AddTickets(tickets []*Ticket, fileOnly bool) {

View file

@ -20,8 +20,9 @@ func (c *Campaign) PrintUserReport() {
} }
fmt.Println("User report:\n") fmt.Println("User report:\n")
w := tabwriter.NewWriter(os.Stdout, 3, 0, 3, ' ', tabwriter.AlignRight) w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', tabwriter.AlignRight)
fmt.Fprintln(w, "GitHub username\tTickets closed\t") fmt.Fprintln(w, "GitHub username\tTickets closed\t")
fmt.Fprintln(w, "---------------\t--------------\t")
for user, count := range userTickets { for user, count := range userTickets {
fmt.Fprintf(w, "%s\t%d\t\n", user, count) fmt.Fprintf(w, "%s\t%d\t\n", user, count)
} }