Documentation ¶
Index ¶
- Constants
- type Argument
- type ArgumentBuilder
- type ArgumentBuilderWithArgument
- type ArgumentBuilderWithLiteral
- type Graph
- func (g *Graph) AddPlayer(p *server.Player)
- func (g *Graph) AppendLiteral(child *Literal) *Graph
- func (g *Graph) Argument(name string, parser Parser) ArgumentBuilder
- func (g *Graph) Execute(ctx context.Context, cmd string) error
- func (g *Graph) Init(game *server.Game)
- func (g *Graph) Literal(str string) LiteralBuilder
- func (g *Graph) RemovePlayer(p *server.Player)
- func (g *Graph) Run(ctx context.Context)
- func (g *Graph) WriteTo(w io.Writer) (int64, error)
- type HandlerFunc
- type Literal
- type LiteralBuilder
- type LiteralBuilderWithArgument
- type LiteralBuilderWithLiteral
- type LiteralData
- type Node
- type ParseErr
- type ParsedData
- type Parser
- type StringParser
Constants ¶
View Source
const ( RootNode = iota LiteralNode ArgumentNode )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 (n ArgumentBuilderWithArgument) HandleFunc(f HandlerFunc) *Argument
func (ArgumentBuilderWithArgument) Unhandle ¶
func (n ArgumentBuilderWithArgument) Unhandle() *Argument
type ArgumentBuilderWithLiteral ¶
type ArgumentBuilderWithLiteral struct {
// contains filtered or unexported fields
}
func (ArgumentBuilderWithLiteral) AppendLiteral ¶
func (n ArgumentBuilderWithLiteral) AppendLiteral(node *Literal) ArgumentBuilderWithLiteral
func (ArgumentBuilderWithLiteral) HandleFunc ¶
func (n ArgumentBuilderWithLiteral) HandleFunc(f HandlerFunc) *Argument
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 (*Graph) AppendLiteral ¶
func (*Graph) Argument ¶
func (g *Graph) Argument(name string, parser Parser) ArgumentBuilder
Argument create a new ArgumentNode in the Graph.
func (*Graph) Literal ¶
func (g *Graph) Literal(str string) LiteralBuilder
Literal create a new LiteralNode in the Graph.
func (*Graph) RemovePlayer ¶
RemovePlayer implement server.Component for Graph
type HandlerFunc ¶
type HandlerFunc func(ctx context.Context, args []ParsedData) error
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 (n LiteralBuilderWithArgument) HandleFunc(f HandlerFunc) *Literal
func (LiteralBuilderWithArgument) Unhandle ¶
func (n LiteralBuilderWithArgument) Unhandle() *Literal
type LiteralBuilderWithLiteral ¶
type LiteralBuilderWithLiteral struct {
// contains filtered or unexported fields
}
func (LiteralBuilderWithLiteral) AppendLiteral ¶
func (n LiteralBuilderWithLiteral) AppendLiteral(node *Literal) LiteralBuilderWithLiteral
func (LiteralBuilderWithLiteral) HandleFunc ¶
func (n LiteralBuilderWithLiteral) HandleFunc(f HandlerFunc) *Literal
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.
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)
Click to show internal directories.
Click to hide internal directories.