switch for only running containers

This commit is contained in:
fabianlee 2017-05-22 16:14:10 +00:00
parent 360c954944
commit 25acff1b44

View file

@ -24,7 +24,7 @@ type Container struct {
type ContainersCommand struct { type ContainersCommand struct {
Dot bool `short:"d" long:"dot" description:"Show container information as Graphviz dot."` Dot bool `short:"d" long:"dot" description:"Show container information as Graphviz dot."`
NoTruncate bool `short:"n" long:"no-trunc" description:"Don't truncate the container IDs."` NoTruncate bool `short:"n" long:"no-trunc" description:"Don't truncate the container IDs."`
//OnlyRunning bool `short:"r" long:"running" description:"Only show running containers, not Exited"` OnlyRunning bool `short:"r" long:"running" description:"Only show running containers, not Exited"`
} }
var containersCommand ContainersCommand var containersCommand ContainersCommand
@ -82,8 +82,7 @@ func (x *ContainersCommand) Execute(args []string) error {
} }
if containersCommand.Dot { if containersCommand.Dot {
//fmt.Printf(jsonContainersToDot(containers, containersCommand.OnlyRunning)) fmt.Printf(jsonContainersToDot(containers, containersCommand.OnlyRunning))
fmt.Printf(jsonContainersToDot(containers, true))
} else { } else {
return fmt.Errorf("Please specify --dot") return fmt.Errorf("Please specify --dot")
} }
@ -140,7 +139,7 @@ func jsonContainersToDot(containers *[]Container,OnlyRunning bool) string {
LinkMap = make(map[string]string) LinkMap = make(map[string]string)
for _, container := range *containers { for _, container := range *containers {
//if OnlyRunning && strings.HasPrefix(container.Status,"Exit") { continue } if OnlyRunning && strings.HasPrefix(container.Status,"Exit") { continue }
var containerName string var containerName string