MCPcopy Index your code
hub / github.com/docker/cli / postFormat

Method postFormat

cli/command/formatter/formatter.go:93–109  ·  view source on GitHub ↗
(tmpl *template.Template, subContext SubContext)

Source from the content-addressed store, hash-verified

91}
92
93func (c *Context) postFormat(tmpl *template.Template, subContext SubContext) {
94 out := c.Output
95 if out == nil {
96 out = io.Discard
97 }
98 if !c.Format.IsTable() {
99 _, _ = c.buffer.WriteTo(out)
100 return
101 }
102
103 // Write column-headers and rows to the tab-writer buffer, then flush the output.
104 tw := tabwriter.NewWriter(out, 10, 1, 3, ' ', 0)
105 _ = tmpl.Funcs(templates.HeaderFunctions).Execute(tw, subContext.FullHeader())
106 _, _ = tw.Write([]byte{'\n'})
107 _, _ = c.buffer.WriteTo(tw)
108 _ = tw.Flush()
109}
110
111func (c *Context) contextFormat(tmpl *template.Template, subContext SubContext) error {
112 if err := tmpl.Execute(c.buffer, subContext); err != nil {

Callers 3

WriteMethod · 0.95
WriteMethod · 0.80
verboseWriteTableMethod · 0.80

Calls 4

WriteMethod · 0.95
FlushMethod · 0.95
IsTableMethod · 0.80
FullHeaderMethod · 0.65

Tested by

no test coverage detected