term

package
v3.8.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminalReader

func IsTerminalReader(r io.Reader) bool

IsTerminalReader returns whether the passed io.Reader is a terminal or not

func IsTerminalWriter

func IsTerminalWriter(w io.Writer) bool

IsTerminalWriter returns whether the passed io.Writer is a terminal or not

func NewMaxWidthWriter

func NewMaxWidthWriter(w io.Writer, maxWidth uint) io.Writer

NewMaxWidthWriter is a Writer that supports a limit of characters on every line, but doesn't do any word wrapping automatically.

func NewPunchCardWriter

func NewPunchCardWriter(w io.Writer) io.Writer

NewPunchCardWriter is a NewWordWrapWriter that limits the line width to 80 columns.

func NewResponsiveWriter

func NewResponsiveWriter(w io.Writer) io.Writer

NewResponsiveWriter creates a Writer that detects the column width of the terminal we are in, and adjusts every line width to fit and use recommended terminal sizes for better readability. Does proper word wrapping automatically.

if terminal width >= 120 columns		use 120 columns
if terminal width >= 100 columns		use 100 columns
if terminal width >=  80 columns		use  80 columns

In case we're not in a terminal or if it's smaller than 80 columns width, doesn't do any wrapping.

func NewWordWrapWriter

func NewWordWrapWriter(w io.Writer, limit uint) io.Writer

NewWordWrapWriter is a Writer that supports a limit of characters on every line and does auto word wrapping that respects that limit.

func PromptForBool

func PromptForBool(r io.Reader, w io.Writer, format string, a ...interface{}) bool

PromptForBool prompts for user input of a boolean value. The accepted values are:

yes, y, true, 	t, 1 (not case sensitive)
no, 	n, false, f, 0 (not case sensitive)

A valid answer is mandatory so it will keep asking until an answer is provided.

func PromptForPasswordString

func PromptForPasswordString(r io.Reader, w io.Writer, format string, a ...interface{}) string

PromptForPasswordString prompts for user input by disabling echo in terminal, useful for password prompt.

func PromptForString

func PromptForString(r io.Reader, w io.Writer, format string, a ...interface{}) string

PromptForString takes an io.Reader and prompts for user input if it's a terminal, returning the result.

func PromptForStringWithDefault

func PromptForStringWithDefault(r io.Reader, w io.Writer, def string, format string, a ...interface{}) string

PromptForStringWithDefault prompts for user input but take a default in case nothing is provided.

Types

This section is empty.

Jump to

Keyboard shortcuts

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