renderer

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	YAML    bool `json:"yaml,omitempty" yaml:"yaml,omitempty"`
	JSON    bool `json:"json,omitempty" yaml:"json,omitempty"`
	CSV     bool `json:"csv,omitempty" yaml:"csv,omitempty"`
	Table   bool `json:"table,omitempty" yaml:"table,omitempty"`
	NoColor bool `json:"no_color,omitempty" yaml:"no_color,omitempty"`
	// contains filtered or unexported fields
}

Config implements methods to render output in JSON/YAML format.

func GetRenderer

func GetRenderer(writer io.Writer, log *logrus.Logger, noColor, yaml, json, csv, table bool) Config

GetRenderer returns the new instance of Config.

func (*Config) ColorJSON added in v0.0.3

func (cfg *Config) ColorJSON(value interface{}) (string, error)

ColorJSON add colors to your JSON string.

func (*Config) ColorYAML added in v0.0.3

func (cfg *Config) ColorYAML(text string) (string, error)

ColorYAML add colors to your YAML string.

func (*Config) Render

func (cfg *Config) Render(value interface{}) error

Render renders the output based on the output format selection (toYAML, toJSON). If none is selected it prints as the source.

func (*Config) ToCSV

func (cfg *Config) ToCSV(value interface{}) error

ToCSV renders the value to CSV format.

func (*Config) ToJSON

func (cfg *Config) ToJSON(value interface{}) error

ToJSON renders the value to JSON format.

func (*Config) ToTable

func (cfg *Config) ToTable(value interface{}) error

ToTable renders the value to Table format.

func (*Config) ToYAML

func (cfg *Config) ToYAML(value interface{}) error

ToYAML renders the value to YAML format.

type Renderer

type Renderer interface {
	ToYAML(value interface{}) error
	ToJSON(value interface{}) error
	ToCSV(value interface{}) error
	ToTable(value interface{}) error
}

Renderer implements methods that Prints values in YAML,JSON,CSV and Table format.

Jump to

Keyboard shortcuts

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