style

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTermenvStyle

func NewTermenvStyle(p termenv.Profile, in FormatPrimitive) termenv.Style

Types

type Config

type Config struct {
	Formatting Formatting `json:"formatting,omitempty" yaml:"formatting,omitempty"`
	Layout     Layout     `json:"layout,omitempty" yaml:"layout,omitempty"`
}

Config holds style configuration.

func DefaultConfig

func DefaultConfig(layoutGoTpl string) *Config

DefaultConfig returns default style config.

type Date

type Date struct {
	EnableHumanizedSuffix bool `json:"enableHumanizedSuffix" yaml:"enableHumanizedSuffix"`
}

Date holds template 'date' func related settings.

type FormatPrimitive

type FormatPrimitive struct {
	Color      string   `json:"color"       yaml:"color"`
	Background string   `json:"background"  yaml:"background"`
	Options    []string `json:"options"     yaml:"options"`
}

FormatPrimitive holds general formatting options.

type Formatting

type Formatting struct {
	Header Header `json:"header" yaml:"header"`
	Key    Key    `json:"key"    yaml:"key"`
	Val    Val    `json:"val"    yaml:"val"`
	Date   Date   `json:"date"   yaml:"date"`
}

Formatting holds formatting settings.

func DefaultFormatting

func DefaultFormatting() Formatting

type GoTemplateRender

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

GoTemplateRender provides a functionality to render input data based on a given style.

func NewGoTemplateRender

func NewGoTemplateRender(cfg *Config) *GoTemplateRender

NewGoTemplateRender returns new GoTemplateRender instance.

func (*GoTemplateRender) Render

func (r *GoTemplateRender) Render(in interface{}, isSmartTerminal bool) (string, error)

Render renders input data based on configured given style. If isSmartTerminal is set to 'true', colors and formatting are used.

type Header struct {
	Prefix          string `json:"prefix"  yaml:"prefix"`
	FormatPrimitive `json:",inline" yaml:",inline"`
}

Header holds template 'header' func related settings.

type KV added in v1.1.0

type KV struct {
	Key   string
	Value any
}

type Key

type Key struct {
	FormatPrimitive `json:",inline"  yaml:",inline"`
}

Key holds template 'key' func related settings.

type Layout

type Layout struct {
	// GoTemplate defines layout in with Go template syntax.
	GoTemplate string `json:"goTemplate,omitempty" yaml:"goTemplate,omitempty"`
}

Layout define the layout for printing the pretty format.

type Val

type Val struct {
	FormatPrimitive `json:",inline"  yaml:",inline"`
}

Val holds template 'val' func related settings.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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