Documentation ¶
Overview ¶
Package term provides TTY helper functions for prompting for passwords etc...
Index ¶
- Constants
- func AnyKey() (err error)
- func IsTTY() bool
- func IsTTYP(fd uintptr) bool
- func Prompt(msg string) (err error)
- func PromptRes(msg string, opts ...string) (res string, err error)
- func WaitForKey(key byte) (err error)
- type TTY
- func (tty *TTY) Close() (err error)
- func (tty *TTY) PromptRes(msg string, opts ...string) (res string, err error)
- func (tty *TTY) ReadChar() (res string, err error)
- func (tty *TTY) ReadLine() (result string, err error)
- func (tty *TTY) ReadPassword() (result string, err error)
- func (tty *TTY) ReadRune() (r rune, err error)
- func (tty *TTY) ReadSensitive() (result string, err error)
- func (tty *TTY) ReadString() (result string, err error)
- func (tty *TTY) Size() (col int, row int, err error)
Constants ¶
const ( // Ascii 0 - 31 plus 127 are control characters KeyNUL = rune(0) KeyBackSpace = rune(8) KeyTab = rune(9) KeyLineFeed = rune(10) KeyReturn = rune(13) KeyEscape = rune(27) KeyDelete = rune(127) KeySpace = rune(32) KeyExclamation = rune(33) KeyQuote = rune(34) KeyHash = rune(35) KeyDollar = rune(36) KeyPercent = rune(37) KeyAmpersand = rune(38) KeyApostrophe = rune(39) KeyLeftParen = rune(40) KeyRightParen = rune(41) KeyAsterisk = rune(42) KeyPlus = rune(43) KeyComma = rune(44) KeyHyphen = rune(45) KeyPeriod = rune(46) KeySlash = rune(47) KeyDigit0 = rune(48) )
Symbol to rune table
Variables ¶
This section is empty.
Functions ¶
func IsTTY ¶ added in v1.1.19
func IsTTY() bool
IsTTY simply checks if we are working with a TTY on os.Stdout
func Prompt ¶
Prompt prints out the given message and waits for any key to be pressed before returning.
func PromptRes ¶
PromptRes prints out the given message and waits for user response terminated by a return. Optionally desired options may be given and the message repeated if not a valid option. Options are not case sensitive
func WaitForKey ¶
WaitForKey waits the given key to be pressed
Types ¶
type TTY ¶
type TTY struct { Stdin *bufio.Reader // input reader Stdout *bufio.Writer // output writer SigWinSizeChan chan os.Signal // signal channel for unix.SIGWINCH // contains filtered or unexported fields }
TTY provides interaction with the system tty
func Open ¶
Open a new TTY helper instance https://github.com/golang/crypto/blob/master/ssh/terminal/util.go
func (*TTY) PromptRes ¶
PromptRes prints out the given message and waits for user response terminated by a return. Optionally desired options may be given and the message repeated if not a valid option. Options are not case sensitive
func (*TTY) ReadLine ¶
ReadLine reads from the TTY until return is pressed i.e. '\r' returned string does not include the trailing '\r'
func (*TTY) ReadPassword ¶
ReadPassword reads from TTY until return is pressed, printing out asterisks in place of echo
func (*TTY) ReadSensitive ¶
ReadSensitive reads from TTY until return is pressed, does not echo
func (*TTY) ReadString ¶
ReadString reads from the TTY until return is pressed and echos back to TTY rune by rune
Directories ¶
Path | Synopsis |
---|---|
Package color provides basic terminal color output via ANSI Escape Codes https://misc.flogisoft.com/bash/tip_colors_and_formatting
|
Package color provides basic terminal color output via ANSI Escape Codes https://misc.flogisoft.com/bash/tip_colors_and_formatting |