formatter

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StyleWithoutGraphics = table.BoxStyle{
	BottomLeft:       " ",
	BottomRight:      " ",
	BottomSeparator:  " ",
	EmptySeparator:   text.RepeatAndTrim(" ", text.RuneWidthWithoutEscSequences(" ")),
	Left:             " ",
	LeftSeparator:    " ",
	MiddleHorizontal: " ",
	MiddleSeparator:  " ",
	MiddleVertical:   " ",
	PaddingLeft:      " ",
	PaddingRight:     " ",
	PageSeparator:    "\n",
	Right:            " ",
	RightSeparator:   " ",
	TopLeft:          " ",
	TopRight:         " ",
	TopSeparator:     " ",
	UnfinishedRow:    " ",
}

StyleWithoutGraphics defines a style without graphics like below: col1 col2 col3 col4 1 477 Elizabeth 12 3 2804 David 33 4 1161 William 81 5 1172 Jack 35 6 1064 William 25

Functions

func MakeOutput

func MakeOutput(format Format, data string, opts Opts) (string, error)

MakeOutput returns formatted output from a YAML data depending on the specified output format and passed formatting options.

Types

type Format

type Format int

Format defines a set of supported output format.

const (
	YamlFormat Format = iota
	LuaFormat
	TableFormat
	TTableFormat
	FormatsAmount
)
const (
	// DefaultFormat is a default format.
	DefaultFormat Format = YamlFormat
)

func ParseFormat

func ParseFormat(str string) (Format, bool)

ParseFormat parses a output format string representation. It supports mixed case letters.

func (Format) String

func (f Format) String() string

String returns a string representation of the output format.

type Opts

type Opts struct {
	// Graphics sets on/off the output of pseudographic characters.
	Graphics bool
	// ColumnWidthMax sets is a maximum width of columns.
	ColumnWidthMax int
	// TableDialect sets a current table dialect.
	TableDialect TableDialect
}

Opts contains formatting options.

type TableDialect

type TableDialect int

TableDialect defines a set of supported table dialect.

const (
	DefaultTableDialect TableDialect = iota
	MarkdownTableDialect
	JiraTableDialect
)

func ParseTableDialect

func ParseTableDialect(str string) (TableDialect, bool)

ParseTableDialect parses a table dialect string representation. It supports mixed case letters.

func (TableDialect) String

func (d TableDialect) String() string

String returns a string representation of the table dialect.

Jump to

Keyboard shortcuts

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