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

Function formatWrite

cli/command/stack/services.go:65–89  ·  view source on GitHub ↗
(dockerCLI command.Cli, services client.ServiceListResult, opts serviceListOptions)

Source from the content-addressed store, hash-verified

63}
64
65func formatWrite(dockerCLI command.Cli, services client.ServiceListResult, opts serviceListOptions) error {
66 // if no services in the stack, print message and exit 0
67 if len(services.Items) == 0 {
68 _, _ = fmt.Fprintln(dockerCLI.Err(), "Nothing found in stack:", opts.namespace)
69 return nil
70 }
71 sort.Slice(services.Items, func(i, j int) bool {
72 return sortorder.NaturalLess(services.Items[i].Spec.Name, services.Items[j].Spec.Name)
73 })
74
75 f := opts.format
76 if len(f) == 0 {
77 if len(dockerCLI.ConfigFile().ServicesFormat) > 0 && !opts.quiet {
78 f = dockerCLI.ConfigFile().ServicesFormat
79 } else {
80 f = formatter.TableFormatKey
81 }
82 }
83
84 servicesCtx := formatter.Context{
85 Output: dockerCLI.Out(),
86 Format: service.NewListFormat(f, opts.quiet),
87 }
88 return service.ListFormatWrite(servicesCtx, services)
89}

Callers 1

runServicesFunction · 0.70

Calls 3

ErrMethod · 0.65
ConfigFileMethod · 0.65
OutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…