command

package
v764.0.0-...-2fbab1c Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 8 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 Client

type Client interface {
	SendPacket(p pk.Packet)
}

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) 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) ClientJoin

func (g *Graph) ClientJoin(client Client)

ClientJoin implement server.Component for Graph

func (*Graph) Execute

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

func (*Graph) Literal

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

Literal create a new LiteralNode in the 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 any

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