console

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package console contains utility functions for working with text consoles

Index

Constants

This section is empty.

Variables

View Source
var Blue = wrap(color.New(color.Blue))

Blue returns the input as a string of blue-coloured text if the console supports colours

View Source
var Bold = wrap(color.New(color.Bold))

Bold returns the input as a string of bold text if the console supports colours

View Source
var Cyan = wrap(color.New(color.Cyan))

Cyan returns the input as a string of cyan-coloured text if the console supports colours

View Source
var Green = wrap(color.New(color.Green))

Green returns the input as a string of green-coloured text if the console supports colours

View Source
var Grey = wrap(color.New(color.Gray))

Grey returns the input as a string of grey-coloured text if the console supports colours

View Source
var IsTTY bool

IsTTY will be true if stdout is connected to a true terminal

View Source
var NoColour = false

NoColour should be false if you want output to be coloured

View Source
var Plain = wrap(color.New(color.Normal))

Plain returns the input as a string of normal-coloured text if the console supports colours

View Source
var Red = wrap(color.New(color.LightRed))

Red returns the input as a string of red-coloured text if the console supports colours

White returns the input as a string of white-coloured text if the console supports colours

View Source
var Yellow = wrap(color.New(color.Yellow))

Yellow returns the input as a string of yellow-coloured text if the console supports colours

Functions

func Ask

func Ask(prompt string) string

Ask prints the supplied prompt and then waits for user input which is returned as a string.

func ClearLine

func ClearLine()

ClearLine removes all text from the current line and puts the cursor on the left

func ClearLines

func ClearLines(n int)

ClearLines removes all text from the previous n lines (starting with the current line) and puts the cursor on the left

func Confirm

func Confirm(defaultYes bool, prompt string) bool

Confirm asks the user for "y" or "n" and returns true if the response was "y". defaultYes is used to determine whether (y/N) or (Y/n) is displayed after the prompt.

func CountLines

func CountLines(input string) int

CountLines returns the number of lines that would be taken up by the given string

func Size

func Size() (int, int)

Size returns the width and height of the console in characters

func Sprint

func Sprint(in ...interface{}) string

Sprint wraps color.Sprint with logic to ignore colours if the console does not support colour

Types

This section is empty.

Directories

Path Synopsis
Package run contains utility functions for executing external commands
Package run contains utility functions for executing external commands
Package spinner contains functions for displaying progress updates with a spinning icon that shows the user that progress is being made.
Package spinner contains functions for displaying progress updates with a spinning icon that shows the user that progress is being made.

Jump to

Keyboard shortcuts

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