aqua

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT, MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package aqua renders bordered unicode tables. Forked from github.com/aquasecurity/table (MIT): behavior preserved except Render propagates no errors (it cannot fail by construction).

Index

Constants

This section is empty.

Variables

View Source
var ASCIIDividers = Dividers{
	ALL: "+",
	NES: "+",
	NSW: "+",
	NEW: "+",
	ESW: "+",
	NE:  "+",
	NW:  "+",
	SW:  "+",
	ES:  "+",
	EW:  "-",
	NS:  "|",
}
View Source
var MarkdownDividers = Dividers{
	ALL: "|",
	NES: "|",
	NSW: "|",
	NE:  "|",
	NW:  "|",
	SW:  "|",
	ES:  "|",
	EW:  "-",
	NS:  "|",
}
View Source
var NoDividers = Dividers{}
View Source
var StarDividers = Dividers{
	ALL: "*",
	NES: "*",
	NSW: "*",
	NEW: "*",
	ESW: "*",
	NE:  "*",
	NW:  "*",
	SW:  "*",
	ES:  "*",
	EW:  "*",
	NS:  "*",
}
View Source
var UnicodeDividers = Dividers{
	ALL: "┼",
	NES: "├",
	NSW: "┤",
	NEW: "┴",
	ESW: "┬",
	NE:  "└",
	NW:  "┘",
	SW:  "┐",
	ES:  "┌",
	EW:  "─",
	NS:  "│",
}
View Source
var UnicodeRoundedDividers = Dividers{
	ALL: "┼",
	NES: "├",
	NSW: "┤",
	NEW: "┴",
	ESW: "┬",
	NE:  "╰",
	NW:  "╯",
	SW:  "╮",
	ES:  "╭",
	EW:  "─",
	NS:  "│",
}

Functions

This section is empty.

Types

type Alignment

type Alignment uint8
const (
	AlignLeft Alignment = iota
	AlignRight
	AlignCenter
	AlignBottom
	AlignTop
)

type Borders

type Borders struct {
	Left   bool
	Top    bool
	Right  bool
	Bottom bool
}

Borders dictates whether to draw lines at the extreme edges of the table

type Dividers

type Dividers struct {
	ALL string
	NES string
	NSW string
	NEW string
	ESW string
	NE  string
	NW  string
	SW  string
	ES  string
	EW  string
	NS  string
}

type Style

type Style int
const (
	StyleNormal    Style = 0
	StyleBold      Style = 1
	StyleDim       Style = 2
	StyleItalic    Style = 3
	StyleUnderline Style = 4

	StyleBlack   Style = 30
	StyleRed     Style = 31
	StyleGreen   Style = 32
	StyleYellow  Style = 33
	StyleBlue    Style = 34
	StyleMagenta Style = 35
	StyleCyan    Style = 36
	StyleWhite   Style = 37

	StyleBrightBlack   Style = 90
	StyleBrightRed     Style = 91
	StyleBrightGreen   Style = 92
	StyleBrightYellow  Style = 93
	StyleBrightBlue    Style = 94
	StyleBrightMagenta Style = 95
	StyleBrightCyan    Style = 96
	StyleBrightWhite   Style = 97
)

type Table

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

Table holds information required to render a table to the terminal

func New

func New(w io.Writer) *Table

New creates a new Table

func (*Table) AddFooters

func (t *Table) AddFooters(footers ...string)

AddFooters adds a row of footers to the table.

func (*Table) AddHeaders

func (t *Table) AddHeaders(headers ...string)

AddHeaders adds a row of headers to the table.

func (*Table) AddRow

func (t *Table) AddRow(cols ...string)

AddRow adds a row to the table. Each argument is a column value.

func (*Table) AddRows

func (t *Table) AddRows(rows ...[]string)

AddRows adds multiple rows to the table. Each argument is a row, i.e. a slice of column values.

func (*Table) Clear

func (t *Table) Clear()

Clear clears the table data

func (*Table) IsEmpty

func (t *Table) IsEmpty() bool

IsEmpty returns if the table has no data

func (*Table) LoadCSV

func (t *Table) LoadCSV(r io.Reader, hasHeaders bool) error

LoadCSV loads CSV data from a reader and adds it to the table. Existing rows/headers/footers are retained.

func (*Table) Render

func (t *Table) Render()

Render writes the table to the provider io.Writer

func (*Table) RowCount

func (t *Table) RowCount() int

RowCount returns the number of rows in the table.

func (*Table) SetAlignment

func (t *Table) SetAlignment(columns ...Alignment)

SetAlignment sets the alignment of each column. Should be specified for each column in the supplied data. Default alignment for columns is AlignLeft

func (*Table) SetAutoMerge

func (t *Table) SetAutoMerge(enabled bool)

SetAutoMerge sets whether to merge cells vertically if their content is the same and non-empty

func (*Table) SetAutoMergeHeaders

func (t *Table) SetAutoMergeHeaders(enabled bool)

SetAutoMergeHeaders sets whether to merge header cells vertically if their content is the same and non-empty

func (*Table) SetAvailableWidth

func (t *Table) SetAvailableWidth(w int)

SetAvailableWidth sets the available width for the table (defaults to terminal width when stdout is used)

func (*Table) SetBorderBottom

func (t *Table) SetBorderBottom(enabled bool)

SetBorderBottom enables/disables the border line on the bottom edge of the table

func (*Table) SetBorderLeft

func (t *Table) SetBorderLeft(enabled bool)

SetBorderLeft enables/disables the border line on the left edge of the table

func (*Table) SetBorderRight

func (t *Table) SetBorderRight(enabled bool)

SetBorderRight enables/disables the border line on the right edge of the table

func (*Table) SetBorderTop

func (t *Table) SetBorderTop(enabled bool)

SetBorderTop enables/disables the border line on the top edge of the table

func (*Table) SetBorders

func (t *Table) SetBorders(enabled bool)

SetBorders enables/disables the border around the table

func (*Table) SetColSpans

func (t *Table) SetColSpans(rowIndex int, colSpans ...int)

SetColSpans sets a column span for each column in the given row.

func (*Table) SetColumnMaxWidth

func (t *Table) SetColumnMaxWidth(maxColumnWidth int)

SetColumnMaxWidth sets the max column width

func (*Table) SetDividers

func (t *Table) SetDividers(d Dividers)

SetDividers allows customisation of the characters used to draw the table. There are several built-in options, such as UnicodeRoundedDividers. Specifying divider values containing more than 1 rune will result in undefined behaviour.

func (*Table) SetFillWidth

func (t *Table) SetFillWidth(enabled bool)

SetFillWidth sets whether to fill the entire available width

func (*Table) SetFooterAlignment

func (t *Table) SetFooterAlignment(columns ...Alignment)

SetFooterAlignment sets the alignment of each footer. Should be specified for each footer in the supplied data. Default alignment for footers is AlignCenter

func (*Table) SetFooterColSpans

func (t *Table) SetFooterColSpans(rowIndex int, colSpans ...int)

SetFooterColSpans sets a column span for each column in the given footer row.

func (*Table) SetFooters

func (t *Table) SetFooters(footers ...string)

SetFooters set the footers used for the table.

func (*Table) SetHeaderAlignment

func (t *Table) SetHeaderAlignment(columns ...Alignment)

SetHeaderAlignment sets the alignment of each header. Should be specified for each header in the supplied data. Default alignment for headers is AlignCenter

func (*Table) SetHeaderColSpans

func (t *Table) SetHeaderColSpans(rowIndex int, colSpans ...int)

SetHeaderColSpans sets a column span for each column in the given header row.

func (*Table) SetHeaderStyle

func (t *Table) SetHeaderStyle(s Style)

SetHeaderStyle set the style used for headers

func (*Table) SetHeaderVerticalAlignment

func (t *Table) SetHeaderVerticalAlignment(a Alignment)

func (*Table) SetHeaders

func (t *Table) SetHeaders(headers ...string)

SetHeaders set the headers used for the table.

func (*Table) SetLineStyle

func (t *Table) SetLineStyle(s Style)

SetLineStyle sets the ANSI style of the lines used when drawing the table. e.g. StyleYellow

func (*Table) SetPadding

func (t *Table) SetPadding(padding int)

SetPadding sets the minimum number of spaces which must surround each column value (horizontally). For example, a padding of 3 would result in a column value such as " hello world " (3 spaces either side)

func (*Table) SetRowLines

func (t *Table) SetRowLines(enabled bool)

SetRowLines sets whether to render horizontal lines between rows

Jump to

Keyboard shortcuts

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