yq/pkg/yqlib/encoder_toml.go

33 lines
717 B
Go
Raw Normal View History

2023-04-03 05:40:06 +00:00
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 {
2023-04-03 05:40:06 +00:00
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")
}
2024-01-11 02:17:34 +00:00
func (te *tomlEncoder) PrintDocumentSeparator(_ io.Writer) error {
2023-04-03 05:40:06 +00:00
return nil
}
2024-01-11 02:17:34 +00:00
func (te *tomlEncoder) PrintLeadingContent(_ io.Writer, _ string) error {
2023-04-03 05:40:06 +00:00
return nil
}
func (te *tomlEncoder) CanHandleAliases() bool {
return false
}