switch for only running containers
This commit is contained in:
parent
360c954944
commit
25acff1b44
1 changed files with 3 additions and 4 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue