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

Function formatInfo

cli/command/system/info.go:483–503  ·  view source on GitHub ↗
(output io.Writer, info dockerInfo, format string)

Source from the content-addressed store, hash-verified

481}
482
483func formatInfo(output io.Writer, info dockerInfo, format string) error {
484 if format == formatter.JSONFormatKey {
485 format = formatter.JSONFormat
486 }
487
488 // Ensure slice/array fields render as `[]` not `null`
489 if info.ClientInfo != nil && info.ClientInfo.Plugins == nil {
490 info.ClientInfo.Plugins = make([]pluginmanager.Plugin, 0)
491 }
492
493 tmpl, err := templates.Parse(format)
494 if err != nil {
495 return cli.StatusError{
496 StatusCode: 64,
497 Status: "template parsing error: " + err.Error(),
498 }
499 }
500 err = tmpl.Execute(output, info)
501 fprintln(output)
502 return err
503}
504
505func fprintf(w io.Writer, format string, a ...any) {
506 _, _ = fmt.Fprintf(w, format, a...)

Callers 3

TestPrettyPrintInfoFunction · 0.85
TestFormatInfoFunction · 0.85
runInfoFunction · 0.85

Calls 2

fprintlnFunction · 0.85
ErrorMethod · 0.45

Tested by 2

TestPrettyPrintInfoFunction · 0.68
TestFormatInfoFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…