Skip to content

Commit

Permalink
Adds properties command
Browse files Browse the repository at this point in the history
  • Loading branch information
rosenhouse committed Jul 31, 2016
1 parent e69226c commit 9db0e00
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions commands/properties.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package commands

import (
"encoding/json"
"fmt"
"os"
)

type Properties struct {
AsJSON bool `short:"j" long:"json" description:"format output as json"`
}

func (command *Properties) Execute(maybeHandle []string) error {
container, err := globalClient().Lookup(handle(maybeHandle))
failIf(err)

properties, err := container.Properties()
failIf(err)

if command.AsJSON {
toPrint, err := json.MarshalIndent(properties, "", " ")
failIf(err)
os.Stdout.Write(toPrint)
} else {
for k, v := range properties {
fmt.Printf("%s:%s\n", k, v)
}
}

return nil
}
1 change: 1 addition & 0 deletions gaol.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func main() {
{"stream-out", "stream data out of the container", &commands.StreamOut{}},
{"net-in", "map a port on the host to a port in the container", &commands.NetIn{}},
{"net-out", "whitelist an IP and port range for a container", &commands.NetOut{}},
{"properties", "list properties for a container", &commands.Properties{}},
}

for _, command := range commands {
Expand Down

0 comments on commit 9db0e00

Please sign in to comment.