From e2597d9791ed6451211cfc3f390ba0fb1722bc6e Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Thu, 24 Sep 2020 14:16:51 +0200 Subject: [PATCH] Modify output formats --- model/campaign.go | 14 +++++++++----- model/campaign_reports.go | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/model/campaign.go b/model/campaign.go index 9b94fde..6c7b30e 100644 --- a/model/campaign.go +++ b/model/campaign.go @@ -4,7 +4,9 @@ import ( "bytes" "fmt" "strings" + "text/tabwriter" "text/template" + "os" "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("\t%d\ttotal tickets\n", totalTickets) - fmt.Printf("\t%d/%d\tpublished in Jira\n", totalPublishedJira, totalTickets) - fmt.Printf("\t%d/%d\tpublished in Github\n", totalPublishedGithub, totalPublishedJira) - fmt.Printf("\t%d/%d\tassigned\n", totalAssigned, totalPublishedGithub) - fmt.Printf("\t%d/%d\tclosed\n\n", totalClosed, totalPublishedGithub) + w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', tabwriter.AlignRight) + fmt.Fprintf(w, " %d\ttotal tickets\t\n", totalTickets) + fmt.Fprintf(w, " %d\tpublished in Jira\t\n", totalPublishedJira) + fmt.Fprintf(w, " %d\tpublished in Github\t\n", 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) { diff --git a/model/campaign_reports.go b/model/campaign_reports.go index 9cf4257..98c8798 100644 --- a/model/campaign_reports.go +++ b/model/campaign_reports.go @@ -20,8 +20,9 @@ func (c *Campaign) PrintUserReport() { } 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, "---------------\t--------------\t") for user, count := range userTickets { fmt.Fprintf(w, "%s\t%d\t\n", user, count) }