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

Function printNames

cli/command/image/tree.go:434–463  ·  view source on GitHub ↗
(out tui.Output, headers []imgColumn, img topImage, color, untaggedColor aec.ANSI)

Source from the content-addressed store, hash-verified

432}
433
434func printNames(out tui.Output, headers []imgColumn, img topImage, color, untaggedColor aec.ANSI) {
435 if len(img.Names) == 0 {
436 _, _ = fmt.Fprint(out, headers[0].Print(untaggedColor, untaggedName))
437 }
438
439 for nameIdx, name := range img.Names {
440 nameWidth := tui.Width(name)
441 lastName := nameIdx == len(img.Names)-1
442 multiLine := nameWidth > headers[0].Width
443
444 _, _ = fmt.Fprint(out, headers[0].Print(color, name))
445
446 // Print each name on its own line, including the last,
447 // unless the last name fits into the column.
448 //
449 // IMAGE ID ...
450 // anImage 171e65262c80 ...
451 // firstName
452 // lastNameIsALongOne
453 // eade5be814e8 ...
454 // anotherLongName
455 // bb747ca923a5 ...
456 if !lastName || multiLine {
457 _, _ = fmt.Fprintln(out)
458 }
459 if multiLine && lastName {
460 _, _ = fmt.Fprint(out, strings.Repeat(" ", headers[0].Width))
461 }
462 }
463}
464
465type alignment int
466

Callers 1

printImageTreeFunction · 0.85

Calls 1

PrintMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…