on truncated output, show canonical name rather than first name

Docker-DCO-1.1-Signed-off-by: Brice Jaglin <bjaglin@teads.tv> (github: bjaglin)
This commit is contained in:
Brice Jaglin
2014-10-10 08:12:15 +02:00
parent 0099b5e68c
commit 4a5cefa173
2 changed files with 61 additions and 9 deletions
+14 -9
View File
@@ -1558,22 +1558,27 @@ func (cli *DockerCli) CmdPs(args ...string) error {
outID = utils.TruncateID(outID)
}
// Remove the leading / from the names
for i := 0; i < len(outNames); i++ {
outNames[i] = outNames[i][1:]
}
if !*quiet {
var (
outCommand = out.Get("Command")
ports = engine.NewTable("", 0)
outNamesList = strings.Join(outNames, ",")
outCommand = out.Get("Command")
ports = engine.NewTable("", 0)
)
outCommand = strconv.Quote(outCommand)
if !*noTrunc {
outCommand = utils.Trunc(outCommand, 20)
outNamesList = outNames[0]
// Keep only the canonical name
for i := 0; i < len(outNames); i++ {
if !strings.Contains(outNames[i][1:], "/") {
outNames = outNames[i : i+1]
break
}
}
}
// Remove the leading / from the names
for i := 0; i < len(outNames); i++ {
outNames[i] = outNames[i][1:]
}
outNamesList := strings.Join(outNames, ",")
ports.ReadListFrom([]byte(out.Get("Ports")))
fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\t%s\t", outID, out.Get("Image"), outCommand, units.HumanDuration(time.Now().UTC().Sub(time.Unix(out.GetInt64("Created"), 0))), out.Get("Status"), api.DisplayablePorts(ports), outNamesList)
if *size {