mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-14 07:08:06 +00:00
13d1bbb45f
Remove dependency on yaml.Node for internal AST representation. Yaml decoder is now just another decoder.
33 lines
733 B
Go
33 lines
733 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(writer io.Writer) error {
|
|
return nil
|
|
}
|
|
|
|
func (te *tomlEncoder) PrintLeadingContent(writer io.Writer, content string) error {
|
|
return nil
|
|
}
|
|
|
|
func (te *tomlEncoder) CanHandleAliases() bool {
|
|
return false
|
|
}
|