(dockerCLI command.Cli, services client.ServiceListResult, opts serviceListOptions)
| 63 | } |
| 64 | |
| 65 | func 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 | } |
no test coverage detected
searching dependent graphs…