console

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: LGPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

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

Variables

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

Functions

This section is empty.

Types

type Config added in v1.0.0

type Config struct {
	Prompter   UserPrompter
	PrompterCh chan string
	Writer     io.Writer
	Neb        Neblet
}

Config neb console config

type Console

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

Console console handler

func New

func New(conf Config) *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 JSVM added in v1.0.0

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

JSVM javascript runtime environment

func (*JSVM) Compile added in v1.0.0

func (v *JSVM) Compile(filename string, src interface{}) error

Compile compiles and then runs JS code.

func (*JSVM) CompleteKeywords added in v1.0.0

func (v *JSVM) CompleteKeywords(line string) []string

CompleteKeywords returns potential continuations for the given line.

func (*JSVM) Get added in v1.0.0

func (v *JSVM) Get(name string) (otto.Value, error)

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

func (*JSVM) JSONString added in v1.0.0

func (v *JSVM) JSONString(val otto.Value) (string, error)

JSONString convert value to json string

func (*JSVM) Run added in v1.0.0

func (v *JSVM) 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 (*JSVM) Set added in v1.0.0

func (v *JSVM) Set(name string, value interface{}) error

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

type Neblet

type Neblet interface {
	Config() *nebletpb.Config
}

Neblet interface breaks cycle import dependency and hides unused services.

type TerminalPrompter added in v1.0.0

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

TerminalPrompter terminal prompter

func NewTerminalPrompter added in v1.0.0

func NewTerminalPrompter() *TerminalPrompter

NewTerminalPrompter create a terminal prompter

func (*TerminalPrompter) AppendHistory added in v1.0.0

func (p *TerminalPrompter) AppendHistory(command string)

AppendHistory appends an entry to the scrollback history.

func (*TerminalPrompter) Prompt added in v1.0.0

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

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

func (*TerminalPrompter) PromptConfirm added in v1.0.0

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 v1.0.0

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 v1.0.0

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 v1.0.0

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 v1.0.0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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