renderer

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 10 Imported by: 5

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"`
	// 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, yaml, json, csv, table bool) Config

GetRenderer returns the new instance of Config.

func (*Config) Render

func (r *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 (r *Config) ToCSV(value interface{}) error

ToCSV renders the value to CSV format.

func (*Config) ToJSON

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

ToJSON renders the value to JSON format.

func (*Config) ToTable

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

ToTable renders the value to Table format.

func (*Config) ToYAML

func (r *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