repl

package
v0.0.0-...-3319774 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 書式設定をリセットするエスケープシーケンス
	ESC_RESET = "\033[0m"
	// 太字にするエスケープシーケンス
	ESC_BOLD = "\033[1m"
	// 文字色を赤色にするエスケープシーケンス
	ESC_RED = "\033[31m"
	// 文字色を黄色にするエスケープシーケンス
	ESC_YELLOW = "\033[33m"
	// 文字色をシアンにするエスケープシーケンス
	ESC_CYAN = "\033[36m"

	// REPLのプロンプト
	PROMPT = ESC_YELLOW + ">>" + ESC_RESET + " "
	// 結果の初めに出力する文字列
	RESULT_HEADER = ESC_CYAN + "=>" + ESC_RESET + " "
	// シークレットロールであることを表すヘッダ文字列
	SECRET_HEADER = ESC_YELLOW + "[secret]" + ESC_RESET + " "

	COMMAND_AST            = "ast"
	COMMAND_EVAL           = "eval"
	COMMAND_ROLL           = "roll"
	COMMAND_SET_DIE_FEEDER = "set-die-feeder"
	COMMAND_SET_DICE_QUEUE = "set-dice-queue"
	COMMAND_SET_GAME       = "set-game"
	COMMAND_LIST_GAMES     = "list-games"

	COMMAND_HELP = "help"
	COMMAND_QUIT = "quit"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// コマンド名
	Name string
	// 引数の説明
	ArgsDescription string
	// 解説
	Description string
	// コマンドハンドラ
	Handler CommandHandler
	// 自動補完の候補
	Completers []readline.PrefixCompleterInterface
}

REPLコマンドを表す構造体。

func (*Command) Usage

func (c *Command) Usage() string

Usage はコマンドの使用方法の説明を返す。

type CommandHandler

type CommandHandler func(r *REPL, c *Command, input string)

コマンドハンドラの型。 返り値は、REPLを終了するならばtrue、続けるならばfalse。

type REPL

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

REPLで使用するデータを格納する構造体。

func New

func New(in io.Reader, out io.Writer) *REPL

New は新しいREPLを構築し、返す。

REPLは、inから入力された文字列をコマンドとして実行し、 outにその結果を出力する。

func (*REPL) Start

func (r *REPL) Start()

Start はREPLを開始する。

Jump to

Keyboard shortcuts

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