neat

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package neat provides a YAML Marshaller that supports colors.

The `ToYAML` function returns neat looking YAML string output using text highlighting with emphasis, colors, and indent helper guide lines to create pleasing and easy to read YAML.

Package neat provides a YAML Marshaller that supports colors.

The `ToString` function returns neat looking YAML string output using text highlighting with emphasis, colors, and indent helper guide lines to create pleasing and easy to read YAML.

Index

Constants

This section is empty.

Variables

View Source
var DefaultColorSchema = map[string]colorful.Color{
	"keyColor":           bunt.IndianRed,
	"indentLineColor":    {R: 0.14, G: 0.14, B: 0.14},
	"scalarDefaultColor": bunt.PaleGreen,
	"boolColor":          bunt.Moccasin,
	"floatColor":         bunt.Orange,
	"intColor":           bunt.MediumPurple,
	"multiLineTextColor": bunt.Aquamarine,
	"nullColor":          bunt.DarkOrange,
	"emptyStructures":    bunt.PaleGoldenrod,
}

DefaultColorSchema is a prepared usable color schema for the neat output processor which is loosly based upon the colors used by Atom

Functions

func Table

func Table(table [][]string, tableOptions ...TableOption) (string, error)

Table renders a string with a well spaced and aligned table output

func ToJSONString

func ToJSONString(obj interface{}) (string, error)

ToJSONString marshals the provided object into JSON with text decorations and is basically just a convenience function to create the output processor and call its `ToJSON` function.

func ToYAMLString

func ToYAMLString(obj interface{}) (string, error)

ToYAMLString marshals the provided object into YAML with text decorations and is basically just a convenience function to create the output processor and call its `ToYAML` function.

Types

type Alignment

type Alignment int

Alignment defines the text alignment option for a table cell.

const (
	Left Alignment = iota
	Right
	Center
)

Table cells support three types of alignment: left, right, center.

type ColumnIndexIsOutOfBoundsError

type ColumnIndexIsOutOfBoundsError struct {
	ColumnIdx int
}

ColumnIndexIsOutOfBoundsError is used to describe that a provided column index is out of bounds

func (*ColumnIndexIsOutOfBoundsError) Error

type EmptyTableError

type EmptyTableError struct {
}

EmptyTableError is used to describe that the input table was either nil, or empty.

func (*EmptyTableError) Error

func (e *EmptyTableError) Error() string

type ImbalancedTableError

type ImbalancedTableError struct {
}

ImbalancedTableError is used to describe that not all rows have the same number of columns

func (*ImbalancedTableError) Error

func (e *ImbalancedTableError) Error() string

type OutputProcessor

type OutputProcessor struct {
	// contains filtered or unexported fields
}

OutputProcessor provides the functionality to output neat YAML strings using colors and text emphasis

func NewOutputProcessor

func NewOutputProcessor(useIndentLines bool, boldKeys bool, colorSchema *map[string]colorful.Color) *OutputProcessor

NewOutputProcessor creates a new output processor including the required internals using the provided preferences

func (*OutputProcessor) ToCompactJSON

func (p *OutputProcessor) ToCompactJSON(obj interface{}) (string, error)

ToCompactJSON processed the provided input object and tries to create a as compact as possible output.

func (*OutputProcessor) ToJSON

func (p *OutputProcessor) ToJSON(obj interface{}) (string, error)

ToJSON processes the provided input object and tries to neatly output it as human readable JSON honoring the preferences provided to the output processor

func (*OutputProcessor) ToYAML

func (p *OutputProcessor) ToYAML(obj interface{}) (string, error)

ToYAML processes the provided input object and tries to neatly output it as human readable YAML honoring the preferences provided to the output processor

type RowLengthExceedsDesiredWidthError

type RowLengthExceedsDesiredWidthError struct {
}

RowLengthExceedsDesiredWidthError is used to describe that the table cannot be rendered, because at least one row exceeds the desired width

func (*RowLengthExceedsDesiredWidthError) Error

type TableOption

type TableOption func(*options)

TableOption defines options/settings for tables.

func AlignCenter

func AlignCenter(cols ...int) TableOption

AlignCenter sets alignment to center for the given columns (referenced by index)

func AlignRight

func AlignRight(cols ...int) TableOption

AlignRight sets alignment to right for the given columns (referenced by index)

func CustomSeparator added in v1.7.0

func CustomSeparator(separator string) TableOption

CustomSeparator set a custom separator string (other than the default single space)

func DesiredWidth

func DesiredWidth(width int) TableOption

DesiredWidth sets the desired width of the table

func VertialBarSeparator

func VertialBarSeparator() TableOption

VertialBarSeparator sets a solid veritcal bar as the column separator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL