renderer

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 16 Imported by: 5

Documentation

Overview

Package renderer provides output rendering and syntax highlighting helpers.

Index

Constants

View Source
const (
	// TypeYAML identifies YAML content for syntax highlighting.
	TypeYAML = "yaml"
	// TypeJSON identifies JSON content for syntax highlighting.
	TypeJSON = "json"
)

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) Color added in v0.0.6

func (cfg *Config) Color(contentType, yamlContent string) (string, error)

Color add colors to your YAML, JSON or any specified string.

func (*Config) Render

func (cfg *Config) Render(value any) 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 any) error

ToCSV renders the value to CSV format.

func (*Config) ToJSON

func (cfg *Config) ToJSON(value any) error

ToJSON renders the value to JSON format.

func (*Config) ToTable

func (cfg *Config) ToTable(value any) error

ToTable renders the value to Table format.

func (*Config) ToYAML

func (cfg *Config) ToYAML(value any) error

ToYAML renders the value to YAML format.

type Renderer

type Renderer interface {
	ToYAML(value any) error
	ToJSON(value any) error
	ToCSV(value any) error
	ToTable(value any) 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