MCPcopy Create free account
hub / github.com/cli/go-gh / ExampleTablePrinter

Function ExampleTablePrinter

example_gh_test.go:281–300  ·  view source on GitHub ↗

Print tabular data to a terminal or in machine-readable format for scripts.

()

Source from the content-addressed store, hash-verified

279
280// Print tabular data to a terminal or in machine-readable format for scripts.
281func ExampleTablePrinter() {
282 terminal := term.FromEnv()
283 termWidth, _, _ := terminal.Size()
284 t := tableprinter.New(terminal.Out(), terminal.IsTerminalOutput(), termWidth)
285
286 red := func(s string) string {
287 return "\x1b[31m" + s + "\x1b[m"
288 }
289
290 // add a field that will render with color and will not be auto-truncated
291 t.AddField("1", tableprinter.WithColor(red), tableprinter.WithTruncate(nil))
292 t.AddField("hello")
293 t.EndRow()
294 t.AddField("2")
295 t.AddField("world")
296 t.EndRow()
297 if err := t.Render(); err != nil {
298 log.Fatal(err)
299 }
300}

Callers

nothing calls this directly

Calls 10

FromEnvFunction · 0.92
NewFunction · 0.92
WithColorFunction · 0.92
WithTruncateFunction · 0.92
SizeMethod · 0.80
OutMethod · 0.80
IsTerminalOutputMethod · 0.80
AddFieldMethod · 0.65
EndRowMethod · 0.65
RenderMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…