Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cli/cobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@ func commandAliases(cmd *cobra.Command) string {
if cmd.HasParent() {
parentPath = cmd.Parent().CommandPath() + " "
}
aliases := cmd.CommandPath()
var aliases strings.Builder
aliases.WriteString(cmd.CommandPath())
for _, alias := range cmd.Aliases {
aliases += ", " + parentPath + alias
aliases.WriteString(", " + parentPath + alias)
}
return aliases
return aliases.String()
}

func topCommands(cmd *cobra.Command) []*cobra.Command {
Expand Down
10 changes: 6 additions & 4 deletions cli/command/container/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
Expand Down Expand Up @@ -61,7 +62,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
const warning = `WARNING! This will remove all stopped containers.
Are you sure you want to continue?`

func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, _ error) {
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())

if !options.force {
Expand All @@ -81,15 +82,16 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
return 0, "", err
}

var out strings.Builder
if len(res.Report.ContainersDeleted) > 0 {
output = "Deleted Containers:\n"
out.WriteString("Deleted Containers:\n")
for _, id := range res.Report.ContainersDeleted {
output += id + "\n"
out.WriteString(id + "\n")
}
spaceReclaimed = res.Report.SpaceReclaimed
}

return spaceReclaimed, output, nil
return spaceReclaimed, out.String(), nil
}

type cancelledErr struct{ error }
Expand Down
14 changes: 8 additions & 6 deletions cli/command/image/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,15 @@ func printImageTree(outs command.Streams, view treeView) {
}(),
Color: &tui.ColorNone,
DetailsValue: func(d *imageDetails) string {
var out string
var b strings.Builder
for _, chip := range possibleChips {
if chip.check(d) {
out += chip.String(isTerm)
b.WriteString(chip.String(isTerm))
} else {
out += chipPlaceholder.String(isTerm)
b.WriteString(chipPlaceholder.String(isTerm))
}
}
return out
return b.String()
},
},
}
Expand Down Expand Up @@ -368,12 +368,14 @@ func adjustColumns(width uint, columns []imgColumn, images []topImage) []imgColu
func generateLegend(out tui.Output, width uint) string {
var legend string
legend += out.Sprint(tui.InfoHeader)
var legendSb371 strings.Builder
for idx, chip := range allChips {
legend += " " + out.Sprint(chip) + " " + chip.desc
legendSb371.WriteString(" " + out.Sprint(chip) + " " + chip.desc)
if idx < len(allChips)-1 {
legend += " |"
legendSb371.WriteString(" |")
}
}
legend += legendSb371.String()

r := int(width) - tui.Width(legend)
if r < 0 {
Expand Down
10 changes: 6 additions & 4 deletions cli/command/network/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
Expand Down Expand Up @@ -58,7 +59,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
const warning = `WARNING! This will remove all custom networks not used by at least one container.
Are you sure you want to continue?`

func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (output string, err error) {
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (output string, _ error) {
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())

if !options.force {
Expand All @@ -78,14 +79,15 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
return "", err
}

var out strings.Builder
if len(res.Report.NetworksDeleted) > 0 {
output = "Deleted Networks:\n"
out.WriteString("Deleted Networks:\n")
for _, id := range res.Report.NetworksDeleted {
output += id + "\n"
out.WriteString(id + "\n")
}
}

return output, nil
return out.String(), nil
}

type cancelledErr struct{ error }
Expand Down
10 changes: 6 additions & 4 deletions cli/command/volume/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
Expand Down Expand Up @@ -68,7 +69,7 @@ Are you sure you want to continue?`
Are you sure you want to continue?`
)

func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, _ error) {
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())

warning := unusedVolumesWarning
Expand Down Expand Up @@ -96,15 +97,16 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
return 0, "", err
}

var out strings.Builder
if len(res.Report.VolumesDeleted) > 0 {
output = "Deleted Volumes:\n"
out.WriteString("Deleted Volumes:\n")
for _, id := range res.Report.VolumesDeleted {
output += id + "\n"
out.WriteString(id + "\n")
}
spaceReclaimed = res.Report.SpaceReclaimed
}

return spaceReclaimed, output, nil
return spaceReclaimed, out.String(), nil
}

type invalidParamErr struct{ error }
Expand Down
Loading