Documentation
¶
Overview ¶
Package formatter renders the results of a Tarantool console request.
A Tarantool console answers with a YAML document; MakeOutput turns that document into the text shown to the user in one of the [Format]s: the YAML itself, a Lua expression, or tables (row per record, or transposed). The table formats take their look from Opts: pseudographics on or off, a maximum column width and a TableDialect (terminal, Markdown or Jira).
The output is what tt prints in its consoles, byte for byte, so a module that renders console results through this package prints them the same way tt's own commands do.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
Types ¶
type Format ¶
type Format int
Format defines a set of supported output format.
const ( // YamlFormat prints the YAML document the console answered with. YamlFormat Format = iota // LuaFormat prints the values as a Lua expression. LuaFormat // TableFormat prints the values as tables, a row per record. TableFormat // TTableFormat prints the values as transposed tables, a column per // record. TTableFormat // FormatsAmount is the number of formats; it is not a format itself. // Every Format is below it, so a console can cycle through them. FormatsAmount )
const ( // DefaultFormat is a default format. DefaultFormat Format = YamlFormat )
func ParseFormat ¶
ParseFormat parses a output format string representation. It supports mixed case letters.
type Opts ¶
type Opts struct {
// Graphics sets on/off the output of pseudographics 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 draws tables for a terminal, with pseudographics // or with spaces as [Opts.Graphics] says. DefaultTableDialect TableDialect = iota // MarkdownTableDialect writes tables to paste into Markdown. MarkdownTableDialect // JiraTableDialect writes tables to paste into Jira. 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.