console

package
v0.0.0-...-39cdb81 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultPrompt = "> "

默认提示是用于用户输入查询的默认提示行前缀。

View Source
const HistoryFile = "history"

HistoryFile是数据目录中用于存储输入回滚的文件。

Variables

View Source
var Stdin = newTerminalPrompter()

stdin保存stdin行阅读器(也使用stdout进行打印提示)。 只有这个读卡器可以用于输入,因为它保留一个内部缓冲区。

Functions

This section is empty.

Types

type Config

type Config struct {
	DataDir  string       //存储控制台历史记录的数据目录
	DocRoot  string       //从何处加载javascript文件的文件系统路径
	Client   *rpc.Client  //通过RPC客户端执行以太坊请求
	Prompt   string       //输入提示前缀字符串(默认为默认提示)
	Prompter UserPrompter //输入提示以允许交互式用户反馈(默认为TerminalPrompter)
	Printer  io.Writer    //要序列化任何显示字符串的输出编写器(默认为os.stdout)
	Preload  []string     //要预加载的javascript文件的绝对路径
}

config是配置的集合,用于微调 javascript控制台。

type Console

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

控制台是一个JavaScript解释的运行时环境。它是一个成熟的 通过外部或进程内RPC连接到运行节点的javascript控制台 客户端。

func New

func New(config Config) (*Console, error)

new初始化javascript解释的运行时环境并设置默认值 使用config结构。

func (*Console) AutoCompleteInput

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

autocompleteinput是一个预先组装好的单词完成器,供用户使用。 输入prompter以向用户提供有关可用方法的提示。

func (*Console) Evaluate

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

evaluate执行代码并将结果漂亮地打印到指定的输出 溪流。

func (*Console) Execute

func (c *Console) Execute(path string) error

执行运行指定为参数的javascript文件。

func (*Console) Interactive

func (c *Console) Interactive()

Interactive启动一个交互式用户会话,在该会话中输入来自 the configured user prompter.

func (*Console) Stop

func (c *Console) Stop(graceful bool) error

停止清理控制台并终止运行时环境。

func (*Console) Welcome

func (c *Console) Welcome()

欢迎显示当前geth实例的摘要和有关 控制台的可用模块。

type UserPrompter

type UserPrompter interface {
	//promptinput向用户显示给定的提示并请求一些文本
	//要输入的数据,返回用户的输入。
	PromptInput(prompt string) (string, error)

	//提示密码向用户显示给定的提示并请求一些文本
	//要输入的数据,但不能回送到终端。
	//方法返回用户提供的输入。
	PromptPassword(prompt string) (string, error)

	//promptconfirm向用户显示给定的提示并请求布尔值
	//做出选择,返回该选择。
	PromptConfirm(prompt string) (bool, error)

	//sethistory设置prompter允许的输入回滚历史记录
	//要回滚到的用户。
	SetHistory(history []string)

	//AppendHistory将一个条目追加到回滚历史记录。应该叫它
	//如果且仅当追加提示是有效命令时。
	AppendHistory(command string)

	//清除历史记录清除整个历史记录
	ClearHistory()

	//setwordCompleter设置提示器将调用的完成函数
	//当用户按Tab键时获取完成候选项。
	SetWordCompleter(completer WordCompleter)
}

userprompter定义控制台提示用户 各种类型的输入。

type WordCompleter

type WordCompleter func(line string, pos int) (string, []string, string)

WordCompleter使用光标位置获取当前编辑的行,并 返回要完成的部分单词的完成候选词。如果 电话是“你好,我!!光标在第一个“!”之前,(“你好, 哇!!,9)传递给可能返回的完成者(“hello,”,“world”, “Word”},“!!!!“你好,世界!!.

Jump to

Keyboard shortcuts

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