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

ttuy

Welcome to the ttuy wiki!

Components

User Input

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

Ask

Prompt

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

Prompt

Yes/No Prompt

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 []row
for i := 0; i < 5; i++ {
	var rowRows = []string{"Cell 1", "Cell 2", "Cell 3", "Cell 4"}
	rows = append(rows, row{columns: rowRows})
}
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