Getting Started

Adding PTerm to Your Project

Make sure to run this command inside your project, when you’re using go modules 😉
PTerm Installation Command
go get

Write Your First Hello World App With PTerm

package main
import (
func main() {
// Create a new header as a fork from pterm.DefaultHeader.
// ┌ new header variable
// │ ┌ Fork it from the default header
// │ │ ┌ Set options
header := pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgRed))
// Print the header centered in your terminal.
// ┌ Use the default CenterPrinter
// │ ┌ Print a string ending with a new line
// │ │ ┌ Use our new header to format the input string
pterm.DefaultCenter.Println(header.Sprint("Hello, World"))
// Print a big text to the terminal.
// ┌ Use the default BigTextPrinter
// │ ┌ Set the Letters option
// | | ┌ Use the PTerm Utils (putils) package to create objects faster
// │ │ | ┌ Generate Letters from string
// │ │ | | ┌ Render output to the console
_ = pterm.DefaultBigText.WithLetters(putils.LettersFromString("Hello")).Render()
// ┌──────────────────────────────────────────────────────────┐
// │There are many more features, which are waiting for you :)│
// └──────────────────────────────────────────────────────────┘
// TODO: If you want, you can try to make the big text centered.

The 4 Printer Categories

If you want to start with PTerm, you have to know the 4 printer categories.

Interactive Printers

Interactive printers respond to user input. Similar to live printers, interactive printers can update their output. This allows the creation of interactive menus and queries. The Show() method shows the interactive prompt in the terminal.
If you need a printer, which a user can interact with, look here:

Can be used for

  • Select Menus
  • Confirm Prompts
  • User Text Input
  • ...

Live Printers

Live printers can update their output dynamically and are therefore well suited to display changing data like progress bars and live charts. They feature a Start() and Stop() method.
If you need a printer, which can update its own content, look here:

Can be used for

  • Live Performance Tracking
  • Visualizing Progress
  • Live Charts
  • Live System Stats
  • ....

Renderable Printers

Renderable printers print text similarily to text printers, but they do not share the same functions as fmt. They have a Render() and Srender() function. This is because the output is to complex and the printer has to be configured to use specific data via options.
If you need a printer, which prints complex output from some sort of data, look here:

Can be used for

  • Charts
  • Tables
  • Statistics
  • ...

Text Printers

Text printers are printers, which can be used like the standard library's fmt package. They have functions, such as Print(), Sprint(), Println(), Sprintln(), Printf(), Sprintf(), Printfln(), Sprintfln(), etc.
If you need a printer, which has a single text input, look here:

Can be used for

  • Debug / Info / Warning / Error / ... Messages
  • Headers
  • Sections
  • Paragraphs
  • ...