use tablewriter to format the output
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
This commit is contained in:
27
internal/app/wwctl/helper/printhelper.go
Normal file
27
internal/app/wwctl/helper/printhelper.go
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user