textui

package
v0.0.0-...-e1d70e2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintBlue

func PrintBlue(format string, a ...interface{})

PrintBlue wraps the fmt.Printf function with ANSI escape codes to color the given text blue.

func PrintError

func PrintError(msg string, a ...interface{})

PrintError writes the given message to stderr

func PrintGreen

func PrintGreen(format string, a ...interface{})

PrintGreen wraps the fmt.Printf function with ANSI escape codes to color the given text green.

func PrintRed

func PrintRed(format string, a ...interface{})

PrintRed wraps the fmt.Printf function with ANSI escape codes to color the given text red.

func PrintWhite

func PrintWhite(format string, a ...interface{})

PrintWhite wraps the fmt.Printf function with ANSI escape codes to color the given text white.

func RunToggleCLI

func RunToggleCLI(exec ToggleExecutor)

RunToggleCLI runs a basic on/off state user interface. The user presses Enter to toggle between states, which will cause the given ToggleExecutor to run.

func SimplePrompt

func SimplePrompt(promptText string) string

SimplePrompt returns the user input for a single prompt

Types

type CLI

type CLI struct {
	PromptText string
	Callback   func(text string)
}

CLI creates a command-line interface that prompts a user for input.

func (*CLI) Run

func (cli *CLI) Run()

Run the CLI until the user presses Ctrl+D to exit.

type ToggleExecutor

type ToggleExecutor interface {
	// GetPrompt returns a string for the given toggle state.
	GetPrompt(toggleState bool) string

	// ToggleOn runs code for the on state.
	ToggleOn()

	// ToggleOff runs code for the off state.
	ToggleOff()
}

ToggleExecutor defines methods to get prompt text and execute functions as the user toggles between on/off states.

Jump to

Keyboard shortcuts

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