use tablewriter to format the output

Signed-off-by: jason yang <jasonyangshadow@gmail.com>
This commit is contained in:
jason yang
2023-03-23 02:44:59 +00:00
parent ceb7859a85
commit 522c3478fb
14 changed files with 144 additions and 51 deletions

View File

@@ -0,0 +1,27 @@
package helper
import (
"os"
"github.com/olekukonko/tablewriter"
)
type PrintHelper struct {
*tablewriter.Table
}
func NewPrintHelper(header []string) *PrintHelper {
tb := tablewriter.NewWriter(os.Stdout)
tb.SetHeader(header)
tb.SetAutoWrapText(false)
tb.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
tb.SetAlignment(tablewriter.ALIGN_LEFT)
tb.SetCenterSeparator("")
tb.SetColumnSeparator("")
tb.SetRowSeparator("")
tb.SetHeaderLine(false)
tb.SetBorder(false)
return &PrintHelper{
Table: tb,
}
}