console

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//APIVersion rpc http version
	APIVersion = "v1"
)

Variables

View Source
var (
	FunctionColor = color.New(color.FgMagenta).SprintfFunc()
	SpecialColor  = color.New(color.Bold).SprintfFunc()
	NumberColor   = color.New(color.FgRed).SprintfFunc()
	StringColor   = color.New(color.FgGreen).SprintfFunc()
	ErrorColor    = color.New(color.FgHiRed).SprintfFunc()
)

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

Functions

This section is empty.

Types

type Console

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

func NewConsole

func NewConsole(conn *grpc.ClientConn) *Console

New a console by Config, neb.config params is need

func (*Console) AutoComplete

func (c *Console) AutoComplete(line string, pos int) (string, []string, string)

AutoComplete console auto complete input

func (*Console) Evaluate

func (c *Console) Evaluate(code string) error

Evaluate executes code and pretty prints the result

func (*Console) Interactive

func (c *Console) Interactive()

Interactive starts an interactive user session.

func (*Console) Setup

func (c *Console) Setup()

Setup setup console

func (*Console) Stop

func (c *Console) Stop() error

Stop stop js console

type JSRE

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

JSRE javascript runtime environment

func (*JSRE) Compile

func (j *JSRE) Compile(filename string, src interface{}) error

Compile compiles and then runs JS code.

func (*JSRE) CompleteKeywords

func (j *JSRE) CompleteKeywords(line string) []string

CompleteKeywords returns potential continuations for the given line.

func (*JSRE) Get

func (j *JSRE) Get(name string) (otto.Value, error)

Get returns the value of a variable in the JS environment.

func (*JSRE) JSONString

func (j *JSRE) JSONString(val otto.Value) (string, error)

JSONString convert value to json string

func (*JSRE) Run

func (j *JSRE) Run(src string) (otto.Value, error)

Run will run the given source (parsing it first if necessary), returning the resulting value and error (if any)

func (*JSRE) Set

func (j *JSRE) Set(name string, value interface{}) error

Set assigns value v to a variable in the JS environment.

type TerminalPrompter

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

TerminalPrompter terminal prompter

func NewTerminalPrompter

func NewTerminalPrompter() *TerminalPrompter

NewTerminalPrompter create a terminal prompter

func (*TerminalPrompter) AppendHistory

func (p *TerminalPrompter) AppendHistory(command string)

AppendHistory appends an entry to the scrollback history.

func (*TerminalPrompter) Prompt

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

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

func (*TerminalPrompter) PromptConfirm

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

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

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

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

func (*TerminalPrompter) SetWordCompleter

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

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