feat: yaml output formatter
This commit is contained in:
@ -6,7 +6,7 @@ import (
|
||||
|
||||
var Formatters = map[string]interfaces.Formatter{
|
||||
"json": &JsonFormatter{},
|
||||
"yaml": nil,
|
||||
"yaml": &YamlFormatter{},
|
||||
"go": &GoFormatter{},
|
||||
"table": nil,
|
||||
}
|
||||
|
||||
19
core/output/yaml.go
Normal file
19
core/output/yaml.go
Normal file
@ -0,0 +1,19 @@
|
||||
package output
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/goccy/go-yaml"
|
||||
)
|
||||
|
||||
type YamlFormatter struct{}
|
||||
|
||||
func (f *YamlFormatter) Format(object any) (io.Reader, error) {
|
||||
buffer, err := yaml.Marshal(object)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return bytes.NewBuffer(buffer), nil
|
||||
}
|
||||
Reference in New Issue
Block a user