@@ -15,6 +15,8 @@ import (
1515 "text/template"
1616
1717 "github.com/olekukonko/tablewriter"
18+ "github.com/olekukonko/tablewriter/renderer"
19+ "github.com/olekukonko/tablewriter/tw"
1820 "github.com/rs/zerolog/log"
1921 "github.com/spf13/cobra"
2022 "go.mondoo.com/cnquery/v12/providers-sdk/v1/lr"
@@ -181,15 +183,38 @@ func (l *lrSchemaRenderer) renderToc(packName string, description string, resour
181183 rows = append (rows , []string {"[" + resource .ID + "](" + mdRef (resource .ID ) + ")" , strings .Join (sanitizeComments ([]string {schema .Resources [resource .ID ].Title }), " " )})
182184 }
183185
184- table := tablewriter .NewWriter (builder )
185- table .SetHeader ([]string {"ID" , "Description" })
186- table .SetHeaderAlignment (tablewriter .ALIGN_LEFT )
187- table .SetAlignment (tablewriter .ALIGN_LEFT )
188- table .SetBorders (tablewriter.Border {Left : true , Top : false , Right : true , Bottom : false })
189- table .SetCenterSeparator ("|" )
190- table .SetAutoWrapText (false )
191- table .AppendBulk (rows )
192- table .Render ()
186+ table := tablewriter .NewTable (builder ,
187+ tablewriter .WithRenderer (renderer .NewBlueprint (tw.Rendition {
188+ Borders : tw.Border {Left : tw .On , Top : tw .Off , Right : tw .On , Bottom : tw .Off },
189+ Symbols : tw .NewSymbolCustom ("cnquery" ).
190+ WithCenter ("|" ).
191+ WithMidLeft ("|" ).
192+ WithMidRight ("|" ),
193+ })),
194+ tablewriter .WithConfig (tablewriter.Config {
195+ Header : tw.CellConfig {
196+ Alignment : tw.CellAlignment {Global : tw .AlignLeft }, // Left-align rows
197+ },
198+ Row : tw.CellConfig {
199+ Alignment : tw.CellAlignment {Global : tw .AlignLeft }, // Left-align rows
200+ Formatting : tw.CellFormatting {
201+ AutoWrap : tw .WrapNone ,
202+ },
203+ },
204+ Footer : tw.CellConfig {
205+ Alignment : tw.CellAlignment {Global : tw .AlignRight },
206+ },
207+ }),
208+ )
209+ table .Header ([]string {"ID" , "Description" })
210+ err = table .Bulk (rows )
211+ if err != nil {
212+ panic (err )
213+ }
214+ err = table .Render ()
215+ if err != nil {
216+ panic (err )
217+ }
193218 builder .WriteString ("\n " )
194219
195220 return builder .String ()
@@ -294,15 +319,38 @@ func (l *lrSchemaRenderer) renderResourcePage(resource *lr.Resource, schema *res
294319 })
295320 }
296321
297- table := tablewriter .NewWriter (builder )
298- table .SetHeader ([]string {"ID" , "Type" , "Description" })
299- table .SetHeaderAlignment (tablewriter .ALIGN_LEFT )
300- table .SetAlignment (tablewriter .ALIGN_LEFT )
301- table .SetBorders (tablewriter.Border {Left : true , Top : false , Right : true , Bottom : false })
302- table .SetCenterSeparator ("|" )
303- table .SetAutoWrapText (false )
304- table .AppendBulk (rows )
305- table .Render ()
322+ table := tablewriter .NewTable (builder ,
323+ tablewriter .WithRenderer (renderer .NewBlueprint (tw.Rendition {
324+ Borders : tw.Border {Left : tw .On , Top : tw .Off , Right : tw .On , Bottom : tw .Off },
325+ Symbols : tw .NewSymbolCustom ("cnquery" ).
326+ WithCenter ("|" ).
327+ WithMidLeft ("|" ).
328+ WithMidRight ("|" ),
329+ })),
330+ tablewriter .WithConfig (tablewriter.Config {
331+ Header : tw.CellConfig {
332+ Alignment : tw.CellAlignment {Global : tw .AlignLeft }, // Left-align rows
333+ },
334+ Row : tw.CellConfig {
335+ Alignment : tw.CellAlignment {Global : tw .AlignLeft }, // Left-align rows
336+ Formatting : tw.CellFormatting {
337+ AutoWrap : tw .WrapNone ,
338+ },
339+ },
340+ Footer : tw.CellConfig {
341+ Alignment : tw.CellAlignment {Global : tw .AlignRight },
342+ },
343+ }),
344+ )
345+ table .Header ([]string {"ID" , "Type" , "Description" })
346+ err := table .Bulk (rows )
347+ if err != nil {
348+ panic (err )
349+ }
350+ err = table .Render ()
351+ if err != nil {
352+ panic (err )
353+ }
306354 builder .WriteString ("\n " )
307355 }
308356
0 commit comments