| 190 | } |
| 191 | |
| 192 | func listOutput(images []podman.Image, containers []podman.Container) { |
| 193 | if len(images) != 0 { |
| 194 | writer := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) |
| 195 | fmt.Fprintf(writer, "%s\t%s\t%s\n", "IMAGE ID", "IMAGE NAME", "CREATED") |
| 196 | |
| 197 | for _, image := range images { |
| 198 | if len(image.Names) != 1 { |
| 199 | panic("cannot list unflattened Image") |
| 200 | } |
| 201 | |
| 202 | fmt.Fprintf(writer, "%s\t%s\t%s\n", |
| 203 | utils.ShortID(image.ID), |
| 204 | image.Names[0], |
| 205 | image.Created) |
| 206 | } |
| 207 | |
| 208 | writer.Flush() |
| 209 | } |
| 210 | |
| 211 | if len(images) != 0 && len(containers) != 0 { |
| 212 | fmt.Println() |
| 213 | } |
| 214 | |
| 215 | if len(containers) != 0 { |
| 216 | const boldGreenColor = "\033[1;32m" |
| 217 | const defaultColor = "\033[0;00m" // identical to resetColor, but same length as boldGreenColor |
| 218 | const resetColor = "\033[0m" |
| 219 | |
| 220 | writer := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) |
| 221 | |
| 222 | if term.IsTerminal(os.Stdout) { |
| 223 | fmt.Fprintf(writer, "%s", defaultColor) |
| 224 | } |
| 225 | |
| 226 | fmt.Fprintf(writer, |
| 227 | "%s\t%s\t%s\t%s\t%s", |
| 228 | "CONTAINER ID", |
| 229 | "CONTAINER NAME", |
| 230 | "CREATED", |
| 231 | "STATUS", |
| 232 | "IMAGE NAME") |
| 233 | |
| 234 | if term.IsTerminal(os.Stdout) { |
| 235 | fmt.Fprintf(writer, "%s", resetColor) |
| 236 | } |
| 237 | |
| 238 | fmt.Fprintf(writer, "\n") |
| 239 | |
| 240 | for _, container := range containers { |
| 241 | isRunning := false |
| 242 | if podman.CheckVersion("2.0.0") { |
| 243 | status := container.Status() |
| 244 | isRunning = status == "running" |
| 245 | } |
| 246 | |
| 247 | if term.IsTerminal(os.Stdout) { |
| 248 | var color string |
| 249 | if isRunning { |