command

package
v1.18.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RootNode = iota
	LiteralNode
	ArgumentNode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument Node

type ArgumentBuilder

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

func (ArgumentBuilder) AppendArgument

func (n ArgumentBuilder) AppendArgument(node *Argument) ArgumentBuilderWithArgument

func (ArgumentBuilder) AppendLiteral

func (n ArgumentBuilder) AppendLiteral(node *Literal) ArgumentBuilderWithLiteral

func (ArgumentBuilder) HandleFunc

func (n ArgumentBuilder) HandleFunc(f HandlerFunc) *Argument

func (ArgumentBuilder) Unhandle

func (n ArgumentBuilder) Unhandle() *Argument

type ArgumentBuilderWithArgument

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

func (ArgumentBuilderWithArgument) HandleFunc

func (ArgumentBuilderWithArgument) Unhandle

func (n ArgumentBuilderWithArgument) Unhandle() *Argument

type ArgumentBuilderWithLiteral

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

func (ArgumentBuilderWithLiteral) AppendLiteral

func (ArgumentBuilderWithLiteral) HandleFunc

func (ArgumentBuilderWithLiteral) Unhandle

func (n ArgumentBuilderWithLiteral) Unhandle() *Argument

type Graph

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

Graph is a directed graph with a root node, representing all commands and how they are parsed.

func NewGraph

func NewGraph() *Graph

func (*Graph) AddPlayer

func (g *Graph) AddPlayer(p *server.Player)

AddPlayer implement server.Component for Graph

func (*Graph) AppendLiteral

func (g *Graph) AppendLiteral(child *Literal) *Graph

func (*Graph) Argument

func (g *Graph) Argument(name string, parser Parser) ArgumentBuilder

Argument create a new ArgumentNode in the Graph.

func (*Graph) Execute

func (g *Graph) Execute(ctx context.Context, cmd string) error

func (*Graph) Init

func (g *Graph) Init(game *server.Game)

Init implement server.Component for Graph

func (*Graph) Literal

func (g *Graph) Literal(str string) LiteralBuilder

Literal create a new LiteralNode in the Graph.

func (*Graph) RemovePlayer

func (g *Graph) RemovePlayer(p *server.Player)

RemovePlayer implement server.Component for Graph

func (*Graph) Run

func (g *Graph) Run(ctx context.Context)

Run implement server.Component for Graph

func (*Graph) WriteTo

func (g *Graph) WriteTo(w io.Writer) (int64, error)

type HandlerFunc

type HandlerFunc func(ctx context.Context, args []ParsedData) error

type Literal

type Literal Node

type LiteralBuilder

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

func (LiteralBuilder) AppendArgument

func (n LiteralBuilder) AppendArgument(node *Argument) LiteralBuilderWithArgument

func (LiteralBuilder) AppendLiteral

func (n LiteralBuilder) AppendLiteral(node *Literal) LiteralBuilderWithLiteral

func (LiteralBuilder) HandleFunc

func (n LiteralBuilder) HandleFunc(f HandlerFunc) *Literal

func (LiteralBuilder) Unhandle

func (n LiteralBuilder) Unhandle() *Literal

type LiteralBuilderWithArgument

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

func (LiteralBuilderWithArgument) HandleFunc

func (LiteralBuilderWithArgument) Unhandle

func (n LiteralBuilderWithArgument) Unhandle() *Literal

type LiteralBuilderWithLiteral

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

func (LiteralBuilderWithLiteral) AppendLiteral

func (LiteralBuilderWithLiteral) HandleFunc

func (LiteralBuilderWithLiteral) Unhandle

func (n LiteralBuilderWithLiteral) Unhandle() *Literal

type LiteralData

type LiteralData string

type Node

type Node struct {
	Name            string
	Children        []int32
	SuggestionsType string
	Parser          Parser
	Run             HandlerFunc
	// contains filtered or unexported fields
}

Node is the node of the Graph. There are 3 kinds of node: Root, Literal and Argument.

func (Node) WriteTo

func (n Node) WriteTo(w io.Writer) (int64, error)

type ParseErr

type ParseErr struct {
	Pos int
	Err string
}

func (ParseErr) Error

func (p ParseErr) Error() string

type ParsedData

type ParsedData interface{}

type Parser

type Parser interface {
	Parse(cmd string) (left string, value ParsedData, err error)
}

type StringParser

type StringParser int32

func (StringParser) Parse

func (s StringParser) Parse(cmd string) (left string, value ParsedData, err error)

func (StringParser) WriteTo

func (s StringParser) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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