Documentation
¶
Index ¶
- Constants
- Variables
- func Colourise(content string, lexer string) (*bytes.Buffer, error)
- func ColouriseBuffer(content *bytes.Buffer, lexer string) error
- func Load(p ReadParser, reader io.Reader, options ...ReadWriteOption) (dasel.Value, error)
- func LoadFromFile(filename string, p ReadParser, options ...ReadWriteOption) (dasel.Value, error)
- func Write(p WriteParser, value dasel.Value, writer io.Writer, options ...ReadWriteOption) error
- type CSVDocument
- type CSVParser
- type JSONParser
- type OptionKey
- type Parser
- type PlainParser
- type ReadParser
- type ReadWriteOption
- func ColouriseOption(enabled bool) ReadWriteOption
- func CsvCommaOption(comma rune) ReadWriteOption
- func CsvCommentOption(comma rune) ReadWriteOption
- func CsvUseCRLFOption(enabled bool) ReadWriteOption
- func EscapeHTMLOption(enabled bool) ReadWriteOption
- func IndentOption(indent string) ReadWriteOption
- func PrettyPrintOption(enabled bool) ReadWriteOption
- type TOMLParser
- type UnknownParserErr
- type WriteParser
- type XMLParser
- type YAMLParser
Constants ¶
const ColouriseFormatter = "terminal"
ColouriseFormatter is the formatter used when colourising output.
const ColouriseStyle = "solarized-dark256"
ColouriseStyle is the style used when colourising output.
Variables ¶
var ErrPlainParserNotImplemented = fmt.Errorf("PlainParser.FromBytes not implemented")
ErrPlainParserNotImplemented is returned when you try to use the PlainParser.FromBytes func.
Functions ¶
func ColouriseBuffer ¶
ColouriseBuffer colourises the given buffer in-place.
func Load ¶
func Load(p ReadParser, reader io.Reader, options ...ReadWriteOption) (dasel.Value, error)
Load loads data from the given io.Reader.
func LoadFromFile ¶
func LoadFromFile(filename string, p ReadParser, options ...ReadWriteOption) (dasel.Value, error)
LoadFromFile loads data from the given file.
func Write ¶
func Write(p WriteParser, value dasel.Value, writer io.Writer, options ...ReadWriteOption) error
Write writes the value to the given io.Writer.
Types ¶
type CSVDocument ¶
CSVDocument represents a CSV file. This is required to keep headers in the expected order.
type CSVParser ¶
type CSVParser struct { }
CSVParser is a Parser implementation to handle csv files.
type JSONParser ¶
type JSONParser struct { }
JSONParser is a Parser implementation to handle json files.
func (*JSONParser) FromBytes ¶
func (p *JSONParser) FromBytes(byteData []byte, options ...ReadWriteOption) (dasel.Value, error)
FromBytes returns some data that is represented by the given bytes.
func (*JSONParser) ToBytes ¶
func (p *JSONParser) ToBytes(value dasel.Value, options ...ReadWriteOption) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.
type OptionKey ¶
type OptionKey string
OptionKey is a defined type for keys within a ReadWriteOption.
const ( // OptionIndent is the key used with IndentOption. OptionIndent OptionKey = "indent" // OptionPrettyPrint is the key used with PrettyPrintOption. OptionPrettyPrint OptionKey = "prettyPrint" // OptionColourise is the key used with ColouriseOption. OptionColourise OptionKey = "colourise" // OptionEscapeHTML is the key used with EscapeHTMLOption. OptionEscapeHTML OptionKey = "escapeHtml" // OptionCSVComma is the key used with CsvCommaOption. OptionCSVComma OptionKey = "csvComma" // OptionCSVComment is the key used with CsvCommentOption. OptionCSVComment OptionKey = "csvComment" // OptionCSVUseCRLF is the key used with CsvUseCRLFOption. OptionCSVUseCRLF OptionKey = "csvUseCRLF" )
type Parser ¶
type Parser interface { ReadParser WriteParser }
Parser can be used to load and save files from/to disk.
type PlainParser ¶
type PlainParser struct { }
PlainParser is a Parser implementation to handle plain files.
func (*PlainParser) FromBytes ¶
func (p *PlainParser) FromBytes(byteData []byte, options ...ReadWriteOption) (dasel.Value, error)
FromBytes returns some data that is represented by the given bytes.
func (*PlainParser) ToBytes ¶
func (p *PlainParser) ToBytes(value dasel.Value, options ...ReadWriteOption) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.
type ReadParser ¶
type ReadParser interface { // FromBytes returns some data that is represented by the given bytes. FromBytes(byteData []byte, options ...ReadWriteOption) (dasel.Value, error) }
ReadParser can be used to convert bytes to data.
func NewReadParserFromFilename ¶
func NewReadParserFromFilename(filename string) (ReadParser, error)
NewReadParserFromFilename returns a ReadParser from the given filename.
func NewReadParserFromString ¶
func NewReadParserFromString(parser string) (ReadParser, error)
NewReadParserFromString returns a ReadParser from the given parser name.
type ReadWriteOption ¶
type ReadWriteOption struct { Key OptionKey Value interface{} }
ReadWriteOption is an option to be used when writing.
func ColouriseOption ¶
func ColouriseOption(enabled bool) ReadWriteOption
ColouriseOption returns an option that enables or disables colourised output.
func CsvCommaOption ¶ added in v2.4.0
func CsvCommaOption(comma rune) ReadWriteOption
CsvCommaOption returns an option that modifies the separator character for CSV files.
func CsvCommentOption ¶ added in v2.4.0
func CsvCommentOption(comma rune) ReadWriteOption
CsvCommentOption returns an option that modifies the comment character for CSV files.
func CsvUseCRLFOption ¶ added in v2.4.0
func CsvUseCRLFOption(enabled bool) ReadWriteOption
CsvUseCRLFOption returns an option that modifies the comment character for CSV files.
func EscapeHTMLOption ¶
func EscapeHTMLOption(enabled bool) ReadWriteOption
EscapeHTMLOption returns an option that enables or disables HTML escaping.
func IndentOption ¶
func IndentOption(indent string) ReadWriteOption
IndentOption returns a write option that sets the given indent.
func PrettyPrintOption ¶
func PrettyPrintOption(enabled bool) ReadWriteOption
PrettyPrintOption returns an option that enables or disables pretty printing.
type TOMLParser ¶
type TOMLParser struct { }
TOMLParser is a Parser implementation to handle toml files.
func (*TOMLParser) FromBytes ¶
func (p *TOMLParser) FromBytes(byteData []byte, options ...ReadWriteOption) (dasel.Value, error)
FromBytes returns some data that is represented by the given bytes.
func (*TOMLParser) ToBytes ¶
func (p *TOMLParser) ToBytes(value dasel.Value, options ...ReadWriteOption) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.
type UnknownParserErr ¶
type UnknownParserErr struct {
Parser string
}
UnknownParserErr is returned when an invalid parser name is given.
func (UnknownParserErr) Error ¶
func (e UnknownParserErr) Error() string
Error returns the error message.
func (UnknownParserErr) Is ¶
func (e UnknownParserErr) Is(other error) bool
type WriteParser ¶
type WriteParser interface { // ToBytes returns a slice of bytes that represents the given value. ToBytes(value dasel.Value, options ...ReadWriteOption) ([]byte, error) }
WriteParser can be used to convert data to bytes.
func NewWriteParserFromFilename ¶
func NewWriteParserFromFilename(filename string) (WriteParser, error)
NewWriteParserFromFilename returns a WriteParser from the given filename.
func NewWriteParserFromString ¶
func NewWriteParserFromString(parser string) (WriteParser, error)
NewWriteParserFromString returns a WriteParser from the given parser name.
type XMLParser ¶
type XMLParser struct { }
XMLParser is a Parser implementation to handle xml files.
type YAMLParser ¶
type YAMLParser struct { }
YAMLParser is a Parser implementation to handle yaml files.
func (*YAMLParser) FromBytes ¶
func (p *YAMLParser) FromBytes(byteData []byte, options ...ReadWriteOption) (dasel.Value, error)
FromBytes returns some data that is represented by the given bytes.
func (*YAMLParser) ToBytes ¶
func (p *YAMLParser) ToBytes(value dasel.Value, options ...ReadWriteOption) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.