Documentation ¶
Index ¶
- Constants
- Variables
- type List
- func (l *List) AppendItem(item interface{})
- func (l *List) AppendItems(items []interface{})
- func (l *List) Indent()
- func (l *List) Length() int
- func (l *List) Render() string
- func (l *List) RenderHTML() string
- func (l *List) RenderMarkdown() string
- func (l *List) Reset()
- func (l *List) SetHTMLCSSClass(cssClass string)
- func (l *List) SetOutputMirror(mirror io.Writer)
- func (l *List) SetStyle(style Style)
- func (l *List) Style() *Style
- func (l *List) UnIndent()
- type Style
- type Writer
Constants ¶
const ( // DefaultHTMLCSSClass stores the css-class to use when none-provided via // SetHTMLCSSClass(cssClass string). DefaultHTMLCSSClass = "go-pretty-table" )
Variables ¶
var ( // StyleDefault renders a List like below: // * Game Of Thrones // * Winter // * Is // * Coming // * This // * Is // * Known // * The Dark Tower // * The Gunslinger StyleDefault = Style{ Format: text.FormatDefault, CharConnectBottom: " ", CharHorizontal: " ", CharItem: "*", CharItemBottom: "*", CharItemFirst: "*", CharItemSingle: "*", CharItemTop: "*", CharPaddingLeft: " ", CharPaddingRight: "", CharVertical: " ", CharVerticalConnect: " ", LinePrefix: "", Name: "StyleDefault", } // StyleBulletCircle renders a List like below: // ● Game Of Thrones // ● Winter // ● Is // ● Coming // ● This // ● Is // ● Known // ● The Dark Tower // ● The Gunslinger StyleBulletCircle = Style{ Format: text.FormatDefault, CharConnectBottom: " ", CharHorizontal: " ", CharItem: text.BulletCircle, CharItemBottom: text.BulletCircle, CharItemFirst: text.BulletCircle, CharItemSingle: text.BulletCircle, CharItemTop: text.BulletCircle, CharPaddingLeft: " ", CharPaddingRight: "", CharVertical: " ", CharVerticalConnect: " ", LinePrefix: "", Name: "StyleBulletCircle", } // StyleBulletFlower renders a List like below: // ✽ Game Of Thrones // ✽ Winter // ✽ Is // ✽ Coming // ✽ This // ✽ Is // ✽ Known // ✽ The Dark Tower // ✽ The Gunslinger StyleBulletFlower = Style{ Format: text.FormatDefault, CharConnectBottom: " ", CharHorizontal: " ", CharItem: text.BulletFlower, CharItemBottom: text.BulletFlower, CharItemFirst: text.BulletFlower, CharItemSingle: text.BulletFlower, CharItemTop: text.BulletFlower, CharPaddingLeft: " ", CharPaddingRight: "", CharVertical: " ", CharVerticalConnect: " ", LinePrefix: "", Name: "StyleBulletFlower", } // StyleBulletSquare renders a List like below: // ■ Game Of Thrones // ■ Winter // ■ Is // ■ Coming // ■ This // ■ Is // ■ Known // ■ The Dark Tower // ■ The Gunslinger StyleBulletSquare = Style{ Format: text.FormatDefault, CharConnectBottom: " ", CharHorizontal: " ", CharItem: text.BulletSquare, CharItemBottom: text.BulletSquare, CharItemFirst: text.BulletSquare, CharItemSingle: text.BulletSquare, CharItemTop: text.BulletSquare, CharPaddingLeft: " ", CharPaddingRight: "", CharVertical: " ", CharVerticalConnect: " ", LinePrefix: "", Name: "StyleBulletSquare", } // StyleBulletStar renders a List like below: // ★ Game Of Thrones // ★ Winter // ★ Is // ★ Coming // ★ This // ★ Is // ★ Known // ★ The Dark Tower // ★ The Gunslinger StyleBulletStar = Style{ Format: text.FormatDefault, CharConnectBottom: " ", CharHorizontal: " ", CharItem: text.BulletStar, CharItemBottom: text.BulletStar, CharItemFirst: text.BulletStar, CharItemSingle: text.BulletStar, CharItemTop: text.BulletStar, CharPaddingLeft: " ", CharPaddingRight: "", CharVertical: " ", CharVerticalConnect: " ", LinePrefix: "", Name: "StyleBulletStar", } // StyleBulletTriangle renders a List like below: // ▶ Game Of Thrones // ▶ Winter // ▶ Is // ▶ Coming // ▶ This // ▶ Is // ▶ Known // ▶ The Dark Tower // ▶ The Gunslinger StyleBulletTriangle = Style{ Format: text.FormatDefault, CharConnectBottom: " ", CharHorizontal: " ", CharItem: text.BulletTrianglePointingRight, CharItemBottom: text.BulletTrianglePointingRight, CharItemFirst: text.BulletTrianglePointingRight, CharItemSingle: text.BulletTrianglePointingRight, CharItemTop: text.BulletTrianglePointingRight, CharPaddingLeft: " ", CharPaddingRight: "", CharVertical: " ", CharVerticalConnect: " ", LinePrefix: "", Name: "StyleBulletTriangle", } // StyleConnectedBold renders a List like below: // ┏━ Game Of Thrones // ┗━┳━ Winter // ┣━ Is // ┣━ Coming // ┣━┳━ This // ┃ ┣━ Is // ┃ ┗━ Known // ┣━ The Dark Tower // ┗━━━ The Gunslinger StyleConnectedBold = Style{ Format: text.FormatDefault, CharConnectBottom: text.BoxBottomLeftBold, CharHorizontal: text.BoxHorizontalBold, CharItem: text.BoxLeftSeparatorBold, CharItemBottom: text.BoxBottomLeftBold, CharItemFirst: text.BoxTopSeparatorBold, CharItemSingle: text.BoxHorizontalBold, CharItemTop: text.BoxTopLeftBold, CharPaddingLeft: text.BoxHorizontalBold, CharPaddingRight: text.BoxHorizontalBold, CharVertical: text.BoxVerticalBold, CharVerticalConnect: text.BoxLeftSeparatorBold, LinePrefix: "", Name: "StyleConnectedBold", } // StyleConnectedDouble renders a List like below: // ╔═ Game Of Thrones // ╚═╦═ Winter // ╠═ Is // ╠═ Coming // ╠═╦═ This // ║ ╠═ Is // ║ ╚═ Known // ╠═ The Dark Tower // ╚═══ The Gunslinger StyleConnectedDouble = Style{ Format: text.FormatDefault, CharConnectBottom: text.BoxBottomLeftDouble, CharHorizontal: text.BoxHorizontalDouble, CharItem: text.BoxLeftSeparatorDouble, CharItemBottom: text.BoxBottomLeftDouble, CharItemFirst: text.BoxTopSeparatorDouble, CharItemSingle: text.BoxHorizontalDouble, CharItemTop: text.BoxTopLeftDouble, CharPaddingLeft: text.BoxHorizontalDouble, CharPaddingRight: text.BoxHorizontalDouble, CharVertical: text.BoxVerticalDouble, CharVerticalConnect: text.BoxLeftSeparatorDouble, LinePrefix: "", Name: "StyleConnectedDouble", } // StyleConnectedLight renders a List like below: // ┌─ Game Of Thrones // └─┬─ Winter // ├─ Is // ├─ Coming // ├─┬─ This // │ ├─ Is // │ └─ Known // ├─ The Dark Tower // └─── The Gunslinger StyleConnectedLight = Style{ Format: text.FormatDefault, CharConnectBottom: text.BoxBottomLeft, CharHorizontal: text.BoxHorizontal, CharItem: text.BoxLeftSeparator, CharItemBottom: text.BoxBottomLeft, CharItemFirst: text.BoxTopSeparator, CharItemSingle: text.BoxHorizontal, CharItemTop: text.BoxTopLeft, CharPaddingLeft: text.BoxHorizontal, CharPaddingRight: text.BoxHorizontal, CharVertical: text.BoxVertical, CharVerticalConnect: text.BoxLeftSeparator, LinePrefix: "", Name: "StyleConnectedLight", } // StyleConnectedRounded renders a List like below: // ╭─ Game Of Thrones // ╰─┬─ Winter // ├─ Is // ├─ Coming // ├─┬─ This // │ ├─ Is // │ ╰─ Known // ├─ The Dark Tower // ╰─── The Gunslinger StyleConnectedRounded = Style{ Format: text.FormatDefault, CharConnectBottom: text.BoxBottomLeftRounded, CharHorizontal: text.BoxHorizontal, CharItem: text.BoxLeftSeparator, CharItemBottom: text.BoxBottomLeftRounded, CharItemFirst: text.BoxTopSeparator, CharItemSingle: text.BoxHorizontal, CharItemTop: text.BoxTopLeftRounded, CharPaddingLeft: text.BoxHorizontal, CharPaddingRight: text.BoxHorizontal, CharVertical: text.BoxVertical, CharVerticalConnect: text.BoxLeftSeparator, LinePrefix: "", Name: "StyleConnectedRounded", } // StyleMarkdown renders a List like below: // * Game Of Thrones // * Winter // * Is // * Coming // * This // * Is // * Known // * The Dark Tower // * The Gunslinger StyleMarkdown = Style{ Format: text.FormatDefault, CharConnectBottom: " ", CharHorizontal: " ", CharItem: "*", CharItemBottom: "*", CharItemFirst: "*", CharItemSingle: "*", CharItemTop: "*", CharPaddingLeft: " ", CharPaddingRight: "", CharVertical: " ", CharVerticalConnect: " ", LinePrefix: " ", Name: "StyleMarkdown", } )
Functions ¶
This section is empty.
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List helps print a 2-dimensional array in a human readable pretty-List.
func (*List) AppendItem ¶
func (l *List) AppendItem(item interface{})
AppendItem appends the item to the List of items to render.
func (*List) AppendItems ¶
func (l *List) AppendItems(items []interface{})
AppendItems appends the items to the List of items to render.
func (*List) Indent ¶
func (l *List) Indent()
Indent indents the following items to appear right-shifted.
func (*List) Render ¶
Render renders the List in a human-readable "pretty" format. Example:
- Game Of Thrones
- Winter
- Is
- Coming
- This
- Is
- Known
- The Dark Tower
- The Gunslinger
func (*List) RenderHTML ¶ added in v1.0.0
RenderHTML renders the List in the HTML format. Example:
<ul class="go-pretty-table"> <li>Game Of Thrones</li> <ul class="go-pretty-table-1"> <li>Winter</li> <li>Is</li> <li>Coming</li> <ul class="go-pretty-table-2"> <li>This</li> <li>Is</li> <li>Known</li> </ul> </ul> <li>The Dark Tower</li> <ul class="go-pretty-table-1"> <li>The Gunslinger</li> </ul> </ul>
func (*List) RenderMarkdown ¶ added in v1.0.0
RenderMarkdown renders the List in the Markdown format. Example:
- Game Of Thrones
- Winter
- Is
- Coming
- This
- Is
- Known
- The Dark Tower
- The Gunslinger
func (*List) Reset ¶ added in v1.0.0
func (l *List) Reset()
Reset sets the List to its initial state.
func (*List) SetHTMLCSSClass ¶ added in v1.0.0
SetHTMLCSSClass sets the the HTML CSS Class to use on the <ul> node when rendering the List in HTML format. Recursive lists would use a numbered index suffix. For ex., if the cssClass is set as "foo"; the <ul> for level 0 would have the class set as "foo"; the <ul> for level 1 would have "foo-1".
func (*List) SetOutputMirror ¶ added in v1.0.0
SetOutputMirror sets an io.Writer for all the Render functions to "Write" to in addition to returning a string.
type Style ¶
type Style struct { Format text.Format CharConnectBottom string CharHorizontal string CharItem string CharItemBottom string CharItemFirst string CharItemSingle string CharItemTop string CharPaddingLeft string CharPaddingRight string CharVertical string CharVerticalConnect string LinePrefix string Name string }
Style declares how to render the List.
type Writer ¶
type Writer interface { AppendItem(item interface{}) AppendItems(items []interface{}) Indent() Length() int Render() string RenderHTML() string RenderMarkdown() string Reset() SetHTMLCSSClass(cssClass string) SetOutputMirror(mirror io.Writer) SetStyle(style Style) Style() *Style UnIndent() }
Writer declares the interfaces that can be used to setup and render a list.