diff --git a/go.mod b/go.mod index 947bbdcd..b16b1030 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +45,8 @@ require ( github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/mitchellh/copystructure v1.0.0 // indirect github.com/mitchellh/reflectwalk v1.0.0 // indirect + github.com/olekukonko/errors v1.1.0 // indirect + github.com/olekukonko/ll v0.0.9 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect @@ -84,7 +86,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/olekukonko/tablewriter v0.0.5 + github.com/olekukonko/tablewriter v1.0.9 github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/stretchr/testify v1.10.0 go.uber.org/ratelimit v0.3.0 diff --git a/go.sum b/go.sum index db152ed8..3de05ed3 100644 --- a/go.sum +++ b/go.sum @@ -108,7 +108,6 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= @@ -124,8 +123,12 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM= +github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y= +github.com/olekukonko/ll v0.0.9 h1:Y+1YqDfVkqMWuEQMclsF9HUR5+a82+dxJuL1HHSRpxI= +github.com/olekukonko/ll v0.0.9/go.mod h1:En+sEW0JNETl26+K8eZ6/W4UQ7CYSrrgg/EdIYT2H8g= +github.com/olekukonko/tablewriter v1.0.9 h1:XGwRsYLC2bY7bNd93Dk51bcPZksWZmLYuaTHR0FqfL8= +github.com/olekukonko/tablewriter v1.0.9/go.mod h1:5c+EBPeSqvXnLLgkm9isDdzR3wjfBkHR9Nhfp3NWrzo= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= diff --git a/pkg/granted/settings/print.go b/pkg/granted/settings/print.go index eab27997..51a4d769 100644 --- a/pkg/granted/settings/print.go +++ b/pkg/granted/settings/print.go @@ -7,6 +7,7 @@ import ( "github.com/common-fate/granted/pkg/config" "github.com/fatih/structs" "github.com/olekukonko/tablewriter" + "github.com/olekukonko/tablewriter/tw" "github.com/urfave/cli/v2" ) @@ -18,8 +19,8 @@ var PrintCommand = cli.Command{ if err != nil { return err } - data := [][]string{ - {"update-checker-api-url", c.String("update-checker-api-url")}, + data := []any{ + []string{"update-checker-api-url", c.String("update-checker-api-url")}, } // display config, this uses reflection to convert the config struct to a map // it will always show all the values in the config without us having to update it @@ -27,21 +28,26 @@ var PrintCommand = cli.Command{ data = append(data, []string{k, fmt.Sprint(v)}) } - table := tablewriter.NewWriter(os.Stderr) - table.SetHeader([]string{"SETTING", "VALUE"}) - table.SetAutoWrapText(false) - table.SetAutoFormatHeaders(true) - table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) - table.SetAlignment(tablewriter.ALIGN_LEFT) - table.SetCenterSeparator("") - table.SetColumnSeparator("") - table.SetRowSeparator("") - table.SetRowLine(true) - table.SetHeaderLine(false) - table.SetBorder(false) - table.SetTablePadding("\t") - table.SetNoWhiteSpace(true) - table.AppendBulk(data) + table := tablewriter.NewTable(os.Stderr, + tablewriter.WithConfig(tablewriter.NewConfigBuilder(). + WithRowAutoWrap(tw.WrapNone). + WithHeaderAutoFormat(tw.On). + WithHeaderAlignment(tw.AlignLeft). + WithRowAlignment(tw.AlignLeft). + WithTrimSpace(tw.On). + Build()), + tablewriter.WithRendition(tw.Rendition{ + Symbols: tw.NewSymbols(tw.StyleNone), + Borders: tw.BorderNone, + Settings: tw.Settings{ + Separators: tw.Separators{ + BetweenRows: tw.On, + }, + }, + }), + ) + table.Header("SETTING", "VALUE") + table.Bulk(data) table.Render() return nil },