yq/pkg/yqlib/encoder_toml.go
Mike Farah 1c9f001171 wip
2024-03-12 16:43:53 +11:00

33 lines
717 B
Go

package yqlib
import (
"fmt"
"io"
)
type tomlEncoder struct {
}
func NewTomlEncoder() Encoder {
return &tomlEncoder{}
}
func (te *tomlEncoder) Encode(writer io.Writer, node *CandidateNode) error {
if node.Kind == ScalarNode {
return WriteString(writer, node.Value+"\n")
}
return fmt.Errorf("only scalars (e.g. strings, numbers, booleans) are supported for TOML output at the moment. Please use yaml output format (-oy) until the encoder has been fully implemented")
}
func (te *tomlEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (te *tomlEncoder) PrintLeadingContent(_ io.Writer, _ string) error {
return nil
}
func (te *tomlEncoder) CanHandleAliases() bool {
return false
}