Skip to content
Closed
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
17 changes: 17 additions & 0 deletions libcontainer/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ const (
Destroyed
)

//Custom type method for returning status as strings
func (s Status) String() string {
switch s {
case Running:
return "Running"
case Pausing:
return "Pausing"
case Paused:
return "Paused"
case Checkpointed:
return "Checkpointed"
case Destroyed:
return "Destroyed"
}
return ""
}

// State represents a running container's state
type State struct {
// ID is the container ID.
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func main() {
pauseCommand,
resumeCommand,
execCommand,
statusCommand,
}
app.Before = func(context *cli.Context) error {
if context.GlobalBool("debug") {
Expand Down
25 changes: 25 additions & 0 deletions status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// +build linux

package main

import (
"fmt"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
)

var statusCommand = cli.Command{
Name: "status",
Usage: "Current status of container",
Action: func(context *cli.Context) {
container, err := getContainer(context)
if err != nil {
fatal(err)
}
status, err := container.Status()
if err != nil {
logrus.Error(err)
}
fmt.Printf("Container ID %s %s\n", context.GlobalString("id"), status)
},
}