Commit 57008336 authored by Adam Reese's avatar Adam Reese

feat(format): add yaml output format

parent fccfcc8e
package main
import (
"fmt"
"os"
"github.com/codegangsta/cli"
......@@ -28,6 +27,5 @@ func list(host string) error {
if err != nil {
return err
}
fmt.Println(list)
return nil
return format.YAML(list)
}
......@@ -3,6 +3,8 @@ package format
import (
"fmt"
"os"
"github.com/ghodss/yaml"
)
// This is all just placeholder.
......@@ -35,3 +37,13 @@ func Warning(msg string, v ...interface{}) {
msg = "[Warning] " + msg + "\n"
fmt.Fprintf(os.Stdout, msg, v...)
}
func YAML(v interface{}) error {
y, err := yaml.Marshal(v)
if err != nil {
return fmt.Errorf("Failed to serialize to yaml: %s", v.(string))
}
Msg(string(y))
return nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment