Skip to content
Brandon Jordan edited this page Sep 24, 2022 · 8 revisions

ttuy

Getting Started

Install

go get github.com/electrikmilk/ttuy

Import

import "github.com/electrikmilk/ttuy"

Components

User Input

var name string
ttuy.Ask("Enter your name", &name)

Ask

Prompt

if ttuy.Prompt("Install Program? This will take up 586kb.") {
	fmt.Println("Installing...")
} else {
	fmt.Println("Installation Canceled.")
}

Prompt

Yes/No Prompt

ttuy.YesNo("Are you sure?")

YesNo

Styled Output

ttuy.Style("Text", ttuy.Bold, ttuy.Green) // returns string
Screen Shot 2022-09-23 at 14 06 15

Menu

ttuy.Menu("Title", []ttuy.Option{
    {
      Label: "Option 1",
      Callback: func() {
        // ...
      },
    },
    {
      Label: "Option 2",
      Callback: func() {
        // ...
      },
      Disabled: true,
    },
    // ...
})

Menu

Table

var headers = []string{"Header 1", "Header 2", "Header 3", "Header 4"}
var rows []ttuy.row
for i := 0; i < 5; i++ {
	var rowRows = []string{"Cell 1", "Cell 2", "Cell 3", "Cell 4"}
	rows = append(rows, ttuy.row{columns: rowRows})
}
ttuy.Table(headers, rows)

Screen Shot 2022-09-23 at 21 46 59

Progress bar

for i := 0; i <= 100; i++ {
    ttuy.Progress(i)
    time.Sleep(100 * time.Millisecond)
}

Progress

Typewriter

ttuy.Typewriter("Typed out one character at a time")

Typewriter

Or time it specifically...

ttuy.TypewriterTimed("Typed out at duration...", 1000)

TypewriterTimed

Print contents of file, some ASCII art for example...

ttuy.File("logo.txt")
Clone this wiki locally