feat: yaml output formatter

This commit is contained in:
2025-07-20 15:28:10 +02:00
parent ef07dd1b86
commit 2e16c67321
5 changed files with 24 additions and 2 deletions

View File

@ -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
View 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
}