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) (interface{}, error)
- func LoadFromFile(filename string, p ReadParser) (interface{}, error)
- func Write(p WriteParser, value interface{}, originalValue interface{}, writer io.Writer, ...) error
- type BasicMultiDocument
- type BasicSingleDocument
- type CSVDocument
- type CSVParser
- type JSONParser
- type MultiDocument
- type OptionKey
- type OriginalRequired
- type Parser
- type PlainParser
- type ReadParser
- type ReadWriteOption
- type RealValue
- type SingleDocument
- 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) (interface{}, error)
Load loads data from the given io.Reader.
func LoadFromFile ¶
func LoadFromFile(filename string, p ReadParser) (interface{}, error)
LoadFromFile loads data from the given file.
func Write ¶
func Write(p WriteParser, value interface{}, originalValue interface{}, writer io.Writer, options ...ReadWriteOption) error
Write writes the value to the given io.Writer.
Types ¶
type BasicMultiDocument ¶
type BasicMultiDocument struct { Values []interface{} // contains filtered or unexported fields }
BasicMultiDocument represents a multi-document file.
func (*BasicMultiDocument) Documents ¶
func (d *BasicMultiDocument) Documents() []interface{}
Documents returns the documents that should be written to output.
func (BasicMultiDocument) OriginalRequired ¶
func (d BasicMultiDocument) OriginalRequired() bool
OriginalRequired tells dasel if the parser requires the original value when converting to bytes.
func (*BasicMultiDocument) RealValue ¶
func (d *BasicMultiDocument) RealValue() interface{}
RealValue returns the real value that dasel should use when processing data.
type BasicSingleDocument ¶
type BasicSingleDocument struct { Value interface{} // contains filtered or unexported fields }
BasicSingleDocument represents a single document file.
func (*BasicSingleDocument) Document ¶
func (d *BasicSingleDocument) Document() interface{}
Document returns the document that should be written to output.
func (BasicSingleDocument) OriginalRequired ¶
func (d BasicSingleDocument) OriginalRequired() bool
OriginalRequired tells dasel if the parser requires the original value when converting to bytes.
func (*BasicSingleDocument) RealValue ¶
func (d *BasicSingleDocument) RealValue() interface{}
RealValue returns the real value that dasel should use when processing data.
type CSVDocument ¶
type CSVDocument struct { Value []map[string]interface{} Headers []string // contains filtered or unexported fields }
CSVDocument represents a CSV file. This is required to keep headers in the expected order.
func (*CSVDocument) Documents ¶
func (d *CSVDocument) Documents() []interface{}
Documents returns the documents that should be written to output.
func (CSVDocument) OriginalRequired ¶
func (d CSVDocument) OriginalRequired() bool
OriginalRequired tells dasel if the parser requires the original value when converting to bytes.
func (*CSVDocument) RealValue ¶
func (d *CSVDocument) RealValue() interface{}
RealValue returns the real value that dasel should use when processing data.
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) (interface{}, error)
FromBytes returns some data that is represented by the given bytes.
func (*JSONParser) ToBytes ¶
func (p *JSONParser) ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.
type MultiDocument ¶
type MultiDocument interface {
Documents() []interface{}
}
MultiDocument is a parser result that contains multiple documents.
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" )
type OriginalRequired ¶
type OriginalRequired interface { // OriginalRequired tells dasel if the parser requires the original value when converting to bytes. OriginalRequired() bool }
OriginalRequired can be used in conjunction with RealValue to allow parsers to be more intelligent with the data they read/write.
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) (interface{}, error)
FromBytes returns some data that is represented by the given bytes.
func (*PlainParser) ToBytes ¶
func (p *PlainParser) ToBytes(value interface{}, 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) (interface{}, 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 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 RealValue ¶
type RealValue interface {
// RealValue returns the real value that dasel should use when processing data.
RealValue() interface{}
}
RealValue can be used in conjunction with OriginalRequired to allow parsers to be more intelligent with the data they read/write.
type SingleDocument ¶
type SingleDocument interface {
Document() interface{}
}
SingleDocument is a parser result that contains a single document.
type TOMLParser ¶
type TOMLParser struct { }
TOMLParser is a Parser implementation to handle toml files.
func (*TOMLParser) FromBytes ¶
func (p *TOMLParser) FromBytes(byteData []byte) (interface{}, error)
FromBytes returns some data that is represented by the given bytes.
func (*TOMLParser) ToBytes ¶
func (p *TOMLParser) ToBytes(value interface{}, 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.
type WriteParser ¶
type WriteParser interface { // ToBytes returns a slice of bytes that represents the given value. ToBytes(value interface{}, 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) (interface{}, error)
FromBytes returns some data that is represented by the given bytes.
func (*YAMLParser) ToBytes ¶
func (p *YAMLParser) ToBytes(value interface{}, options ...ReadWriteOption) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.