mirror of https://github.com/docker/cli.git
Compare commits
4 Commits
3c35f90a4e
...
84ec3c09c6
Author | SHA1 | Date |
---|---|---|
Sebastiaan van Stijn | 84ec3c09c6 | |
Sebastiaan van Stijn | 81401f37f2 | |
Giedrius Jonikas | cb2f95ceee | |
Sebastiaan van Stijn | 7187c78554 |
|
@ -287,16 +287,26 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
|
|||
cStats.mu.RUnlock()
|
||||
|
||||
if !options.NoStream {
|
||||
// Start by clearing the screen and moving the cursor to the top-left
|
||||
_, _ = fmt.Fprint(&statsTextBuffer, "\033[2J\033[H")
|
||||
// Start by moving the cursor to the top-left
|
||||
_, _ = fmt.Fprint(&statsTextBuffer, "\033[H")
|
||||
}
|
||||
|
||||
if err = statsFormatWrite(statsCtx, ccStats, daemonOSType, !options.NoTrunc); err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprint(dockerCLI.Out(), statsTextBuffer.String())
|
||||
if !options.NoStream {
|
||||
for _, line := range strings.Split(statsTextBuffer.String(), "\n") {
|
||||
// In case the new text is shorter than the one we are writing over,
|
||||
// we'll append the "erase line" escape sequence to clear the remaining text.
|
||||
_, _ = fmt.Fprint(&statsTextBuffer, line, "\033[K\n")
|
||||
}
|
||||
|
||||
// We might have fewer containers than before, so let's clear the remaining text
|
||||
_, _ = fmt.Fprint(&statsTextBuffer, "\033[J")
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprint(dockerCLI.Out(), statsTextBuffer.String())
|
||||
statsTextBuffer.Reset()
|
||||
|
||||
if len(cStats.cs) == 0 && !showAll {
|
||||
|
|
|
@ -81,12 +81,30 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error
|
|||
|
||||
details.ContentSize = units.HumanSizeWithPrecision(float64(totalContent), 3)
|
||||
|
||||
view.images = append(view.images, topImage{
|
||||
Names: img.RepoTags,
|
||||
Details: details,
|
||||
Children: children,
|
||||
created: img.Created,
|
||||
})
|
||||
if len(img.RepoTags) == 0 {
|
||||
// Untagged image
|
||||
view.images = append(view.images, topImage{
|
||||
Names: img.RepoTags,
|
||||
Details: details,
|
||||
Children: children,
|
||||
created: img.Created,
|
||||
})
|
||||
} else {
|
||||
// Sort same images alphabetically to keep a consistent sort order.
|
||||
// We can remove this if we decide to sort the list by name, instead
|
||||
// of by "created" date.
|
||||
sort.Strings(img.RepoTags)
|
||||
|
||||
// Present images tagged under multiple names as separate images.
|
||||
for _, n := range img.RepoTags {
|
||||
view.images = append(view.images, topImage{
|
||||
Names: []string{n}, // Consider changing Names to be a single name for purpose of this presentation.
|
||||
Details: details,
|
||||
Children: children,
|
||||
created: img.Created,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(view.images, func(i, j int) bool {
|
||||
|
|
Loading…
Reference in New Issue