MCPcopy Index your code
hub / github.com/rilldata/rill / PrintData

Method PrintData

cli/pkg/printer/printer.go:80–103  ·  view source on GitHub ↗
(v interface{})

Source from the content-addressed store, hash-verified

78}
79
80func (p *Printer) PrintData(v interface{}) {
81 out := p.dataOut()
82 switch p.Format {
83 case FormatHuman:
84 var b strings.Builder
85 tableprinter.Default.RowCharLimit = 120
86 tableprinter.Print(&b, v)
87 fmt.Fprint(out, b.String())
88 case FormatJSON:
89 buf, err := json.MarshalIndent(v, "", " ")
90 if err != nil {
91 panic(fmt.Errorf("failed to marshal JSON: %w", err))
92 }
93 fmt.Fprintln(out, string(buf))
94 case FormatCSV:
95 buf, err := gocsv.MarshalString(v)
96 if err != nil {
97 panic(fmt.Errorf("failed to marshal CSV: %w", err))
98 }
99 fmt.Fprint(out, buf)
100 default:
101 panic(fmt.Errorf("unexpected print format <%v>", p.Format))
102 }
103}
104
105func (p *Printer) PrintDataWithTitle(v interface{}, title string) {
106 if p.Format == FormatHuman {

Callers 15

PrintDataWithTitleMethod · 0.95
PrintOrgsMethod · 0.95
PrintProjectsMethod · 0.95
PrintUsersMethod · 0.95
PrintServicesMethod · 0.95
PrintServiceTokensMethod · 0.95
PrintUserTokensMethod · 0.95

Calls 4

dataOutMethod · 0.95
PrintMethod · 0.80
StringMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected