util

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: LGPL-3.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

Stdin holds the stdin line reader (also using stdout for printing prompts).

Functions

func GenerateRandomAoB

func GenerateRandomAoB(length int64) []byte

func IntToHex

func IntToHex(num int64) []byte

IntToHex converts an int64 to a byte array

func IsTimeOut added in v0.1.2

func IsTimeOut(start, timeOut int64) bool

func UintToHex added in v0.1.2

func UintToHex(num uint64) []byte

UintToHex converts an uint64 to a byte array TODO Same as IntToHex, need refactor

Types

type TerminalPrompter added in v0.1.2

type TerminalPrompter struct {
	// contains filtered or unexported fields
}

TerminalPrompter terminal prompter

func NewTerminalPrompter added in v0.1.2

func NewTerminalPrompter() *TerminalPrompter

NewTerminalPrompter create a terminal prompter

func (*TerminalPrompter) AppendHistory added in v0.1.2

func (p *TerminalPrompter) AppendHistory(command string)

AppendHistory appends an entry to the scrollback history.

func (*TerminalPrompter) GetPassPhrase added in v0.1.2

func (p *TerminalPrompter) GetPassPhrase(prompt string, confirmation bool) string

getPassPhrase get passphrase from consle

func (*TerminalPrompter) Prompt added in v0.1.2

func (p *TerminalPrompter) Prompt(prompt string) (string, error)

Prompt shows the prompt and requests text input returning the input.

func (*TerminalPrompter) PromptConfirm added in v0.1.2

func (p *TerminalPrompter) PromptConfirm(prompt string) (bool, error)

PromptConfirm shows the prompt to the user and requests a boolean choice to be made, returning that choice.

func (*TerminalPrompter) PromptPassphrase added in v0.1.2

func (p *TerminalPrompter) PromptPassphrase(prompt string) (passwd string, err error)

PromptPassphrase shows the prompt and request passphrase text input, the passphrase not show, returns the passphrase

func (*TerminalPrompter) SetHistory added in v0.1.2

func (p *TerminalPrompter) SetHistory(history []string)

SetHistory sets the history that the prompter will allow the user to scroll back to.

func (*TerminalPrompter) SetWordCompleter added in v0.1.2

func (p *TerminalPrompter) SetWordCompleter(completer liner.WordCompleter)

SetWordCompleter sets the completion function that the prompter will call to fetch completion candidates when the user presses tab.

type UserPrompter added in v0.1.2

type UserPrompter interface {
	Prompt(prompt string) (string, error)
	PromptPassphrase(prompt string) (passwd string, err error)
	PromptConfirm(prompt string) (bool, error)
	SetHistory(history []string)
	AppendHistory(command string)
	SetWordCompleter(completer liner.WordCompleter)
}

UserPrompter handle console user input interactive

Jump to

Keyboard shortcuts

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