Skip to content

Commit

Permalink
Better output for plurals
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Sep 29, 2023
1 parent b28693f commit 2a9e74a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions docker-ps.10s.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,28 @@ func defaultCmd(ctx context.Context) {

if len(networks) != 0 {
fmt.Println("---")
fmt.Printf("%d networks\n", len(networks))

msg := fmt.Sprintf("%d network", len(networks))
if len(networks) > 1 {
msg += "s"
}
fmt.Println(msg)

for _, n := range networks {
fmt.Printf("%s (%s)\n", n.Name, n.Driver)
}
}

if len(volumes) != 0 {
var anonymous int
fmt.Println("---")
fmt.Printf("%d volumes\n", len(volumes))

msg := fmt.Sprintf("%d volume", len(volumes))
if len(volumes) > 1 {
msg += "s"
}
fmt.Println(msg)

var anonymous int
for _, v := range volumes {
if v.anonymous() {
anonymous++
Expand Down

0 comments on commit 2a9e74a

Please sign in to comment.