gkp

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DummyKey is a string that GetKeyPushed() returns if set. Use this for testing.
	DummyKey string = ""
	// DummyErr is an error message that GetKeyPushed() returns if set. Use this for testing.
	DummyErr error = nil
	// UserInput is a string that GetKeyPushed() returns if set. Use this for testing.
	// It will override the user input.
	UserInput string = ""
	// OsExit is a copy of os.Exit to ease mock the application exit.
	OsExit func(code int) = os.Exit
)
View Source
var DummyIsTTY bool = false

DummyIsTTY is a bool that IsTTY() returns if set. Use this for testing.

View Source
var TTYOpen func() (*tty.TTY, error) = tty.Open

TTYOpen is a copy of tty.Open() to ease testing. Override the function for testing.

Functions

func GetKeyPushed

func GetKeyPushed(keyDefault string, timeWait int) (keyPushed string, err error)

GetKeyPushed returns the single key pressed by the user via tty(terminal).

It is useful to get the user input without entering `enter` key.

func IsTTY

func IsTTY() bool

IsTTY returns false if the program is not running from terminal.

func OpenTTY

func OpenTTY() (t *tty.TTY, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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