tcl

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

README

tcl   Go Reference Latest Release

tcl stands for terminal component library and provides some "compoents" for nicely formatted terminal outputs.

Badges

last-commit release-date issues prs contributors size loc activity

Table of content

Installation

go get github.com/1H0/tcl

Documentation

Go Reference

Examples

tcl.Footer()
tcl.FooterC("1H0")

footers

Headers
tcl.Header("your app @ v 0.1.0")

headers

Key-Value Pairs
tcl.KeyValue("Lorem", "Ipsum", 0)
tcl.KeyValue("Dolor", "Sit", 0)
tcl.ListItemU("Lorem", 0)
tcl.KeyValue("Amet", "Consectetur", 1)

key-value

Lists
Single Unordered List Items
tcl.ListItemU("Lorem", 0)
tcl.ListItemU("Ipsum", 0)
tcl.ListItemU("Dolor", 0)
tcl.ListItemU("Sit", 1)
tcl.ListItemU("Amet", 1)
tcl.ListItemU("Consectetur", 2)

ul-items

Single Ordered List Items
tcl.ListItemO("Lorem", 0, 1)
tcl.ListItemO("Ipsum", 0, 2)
tcl.ListItemO("Dolor", 0, 3)
tcl.ListItemO("Sit", 1, 1)
tcl.ListItemO("Amet", 1, 2)
tcl.ListItemO("Consectetur", 2, 1)

ol-items

Unordered List by Array
tcl.ListU([]string{"Lorem", "Ipsum", "Dolor"}, 0)
tcl.ListU([]string{"Sit", "Amet"}, 1)
tcl.ListU([]string{"Consectetur"}, 2)

ul-list

Ordered List by Array
tcl.ListO([]string{"Lorem", "Ipsum", "Dolor"}, 0)
tcl.ListO([]string{"Sit", "Amet"}, 1)
tcl.ListO([]string{"Consectetur"}, 2)

ol-list

Messages
tcl.Message("Lorem", "This is a 'black' message", "black")
tcl.Message("Lorem", "This is a 'blue' message", "blue")
tcl.Message("Lorem", "This is a 'cyan' message", "cyan")
tcl.Message("Lorem", "This is a 'green' message", "green")
tcl.Message("Lorem", "This is a 'magenta' message", "magenta")
tcl.Message("Lorem", "This is a 'red' message", "red")
tcl.Message("Lorem", "This is a 'white' message", "white")
tcl.Message("Lorem", "This is a 'yellow' message", "yellow")
tcl.Message("Lorem", "This is a 'default' message", "")

messages

Quotes
tcl.Quote("Lorem ipsum dolor sit amet.")

quotes

Rulers
tcl.Ruler("/")
tcl.Ruler("- ")
tcl.Ruler("=")
tcl.Ruler(" - ")
tcl.Ruler(" = ")
tcl.Ruler("")

rulers

Text
tcl.Text("Lorem Ipsum Dolor Sit Amet.")

texts

Titles
tcl.Title("The normal title")
tcl.TitleC("The centered title")
tcl.FullTitle("A Title that spans the whole width")
tcl.SubTitle("The subtitle")

titles

Tables
tcl.Table([]string{"Col 1", "Col 2", "Col 3"}, [][]string{
  {"Lorem", "Ipsum", "Dolor"},
  {"Lorem", "Ipsum", "Dolor"},
  {"Lorem", "Ipsum", "Dolor"},
})

Tables

ToDo

  • Nested Lists
  • Tests
  • Ability to loop over Struct and print entrys as key-value pairs
  • Tables
  • Customizable Colors and other settings like indentation

Credits

  • @fatih and the maintainers of the fatih/color for providing the main dependency of this package

License

The GNU GENERAL PUBLIC LICENSE - see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Footer()

Footer prints a simple dashed line. It can be used at the end of your output to separate it from the following one.

func FooterC

func FooterC(name string)

FooterC does alsmost the same as the Footer() function, but adds a copyright notice with the provided name and the current year in the center of the dashed line.

func FullTitle

func FullTitle(title string)

FullTitle prints out a title that is as wide as your terminal is.

func Header(text string)

Header prints out a provided text as a centered message, which can be used to display program names. An example would be to display the program name, along with the current version as shown below

tcl.Header("My Program @ v0.1.0")

func KeyValue

func KeyValue(key string, value string, indentation int)

KeyValue lets you provide a 'key' and a 'value' as strings, which then will be printed as a pair to the console. Because the key-value pair is presetnted as a unordered list item, you can specify a indentation via the 'indentation' parameter.

func ListItemO

func ListItemO(text string, indentation int, number int)

ListItemO takes a string and displays it as a ordered list item. With the indentation parameter you can specify if and how deep you want to indent the entry, which might be useful is you want to nest entries. With the number parameter, you can specify the number that is displayed before the entry.

func ListItemU

func ListItemU(text string, indentation int)

ListItemU takes a string and displays it as a unordered list item. With the indentation parameter you can specify if and how deep you want to indent the entry, which might be useful is you want to nest entries.

func ListO

func ListO(list []string, indentation int)

ListO creates a ordered list from a provided array of strings.

func ListU

func ListU(list []string, indentation int)

ListU creates a unordered list from a provided array of strings.

func Message

func Message(title string, message string, color string)

Message let's you print a title along with a message to the console. With the color parameter, you can specify the background color of the title. This is useful if you want to underline a result of a action that was taken, for example a green message after a successful action. The possible and allowed colors are:

  • black
  • blue
  • cyan
  • green
  • magenta
  • red
  • white
  • yellow

If you don't specify a valid color, a white message will be printed.

func NewLines

func NewLines(count int)

newLines does print any number of newlines provided as a parameter.

func Quote

func Quote(text string)

Quote let's you print a simple quote to the console.

func Ruler

func Ruler(c string)

Ruler lets you print a horizontal ruler to the console consisting of the provided caracter(s).

func SubTitle

func SubTitle(title string)

SubTitle prints a subtitle that is bold and underlined.

func Table added in v0.2.0

func Table(headings []string, data [][]string)

func Text

func Text(text string)

Text simply prints the provided text to the console, while respecting the default indent set.

func Title

func Title(title string)

Title prints a title with backgorund and text in uppercase.

func TitleC

func TitleC(title string)

TitleC is like Title() but is centered in the console.

Types

This section is empty.

Jump to

Keyboard shortcuts

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