From 647b38ccb8289073d49037df3d6acaf3ebe23c3a Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Mon, 31 Dec 2018 16:47:53 +0100 Subject: [PATCH] Beautify table view a bit --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 40247c5..0d4b8c3 100644 --- a/main.go +++ b/main.go @@ -68,10 +68,10 @@ func fetchQueueEntries() ([]parser.QEntry, error) { } func printQueueEntries(entries []parser.QEntry, writer io.Writer) { - tabWriter := tabwriter.NewWriter(writer, 0, 2, 1, ' ', tabwriter.TabIndent) - fmt.Fprintf(tabWriter, "%s\t%s\t%s\t%s\t%s\t%s\n", "Date", "Id", "Size", "Sender", "#", "First Recipient") + tabWriter := tabwriter.NewWriter(writer, 2, 2, 1, ' ', tabwriter.TabIndent) + fmt.Fprintf(tabWriter, "| %s\t| %s\t| %s\t| %s\t| %s\t| %s\t| %s\t| \n", "Date", "Id", "Size", "Sender", "#", "First Recipient", "Reason") for _, entry := range entries { - _, writeError := fmt.Fprintf(tabWriter, "%s\t%s\t%d\t%s\t{%d}\t%s\n", entry.Date, entry.Id, entry.Size, entry.Sender, len(entry.Recipients), entry.Recipients[0]) + _, writeError := fmt.Fprintf(tabWriter, "| %s\t| %s\t| %d\t| %s\t| {%d}\t| %s\t| %s\t \n", entry.Date, entry.Id, entry.Size, entry.Sender, len(entry.Recipients), entry.Recipients[0], entry.Reason) if writeError != nil { // A writeError is expected once the reader was closed // This happens when the pager application got terminated @@ -83,7 +83,7 @@ func printQueueEntries(entries []parser.QEntry, writer io.Writer) { } func launchPager(reader *io.PipeReader, pagerDone chan<- bool) { - cmd := exec.Command("less") + cmd := exec.Command("less", "--chop-long-lines") cmd.Stdin = reader cmd.Stdout = os.Stdout if err := cmd.Start(); err != nil {