(ctx context.Context, dockerCLI command.Cli, options *psOptions)
| 115 | } |
| 116 | |
| 117 | func runPs(ctx context.Context, dockerCLI command.Cli, options *psOptions) error { |
| 118 | if len(options.format) == 0 { |
| 119 | // load custom psFormat from CLI config (if any) |
| 120 | options.format = dockerCLI.ConfigFile().PsFormat |
| 121 | } else if options.quiet { |
| 122 | _, _ = dockerCLI.Err().Write([]byte("WARNING: Ignoring custom format, because both --format and --quiet are set.\n")) |
| 123 | } |
| 124 | |
| 125 | listOptions, err := buildContainerListOptions(options) |
| 126 | if err != nil { |
| 127 | return err |
| 128 | } |
| 129 | |
| 130 | res, err := dockerCLI.Client().ContainerList(ctx, listOptions) |
| 131 | if err != nil { |
| 132 | return err |
| 133 | } |
| 134 | |
| 135 | containerCtx := formatter.Context{ |
| 136 | Output: dockerCLI.Out(), |
| 137 | Format: formatter.NewContainerFormat(options.format, options.quiet, listOptions.Size), |
| 138 | Trunc: !options.noTrunc, |
| 139 | } |
| 140 | return formatter.ContainerWrite(containerCtx, res.Items) |
| 141 | } |
no test coverage detected
searching dependent graphs…