command

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForward = errors.New("forward command")

Functions

func Command

func Command(fn func(c *Context) error) brigodier.Command

Command wraps the context for a brigodier.Command.

func ContextWithSource

func ContextWithSource(ctx context.Context, src Source) context.Context

ContextWithSource returns a new context including the specified Source.

func Requires

func Requires(fn func(c *RequiresContext) bool) func(context.Context) bool

Requires wraps the context for a brigodier.RequireFn.

Types

type Context

type Context struct {
	*brigodier.CommandContext
	Source
}

Context wraps the context for a brigodier.Command.

type Manager

type Manager struct{ brigodier.Dispatcher }

Manager is a command manager for registering and executing proxy commands.

func (*Manager) CompletionSuggestions

func (m *Manager) CompletionSuggestions(parse *ParseResults) (*brigodier.Suggestions, error)

CompletionSuggestions returns completion suggestions.

func (*Manager) Do

func (m *Manager) Do(ctx context.Context, src Source, command string) error

Do does a Parse and Execute.

func (*Manager) Execute

func (m *Manager) Execute(parse *ParseResults) error

Execute ensures parse context has a Source and executes it.

func (*Manager) Has

func (m *Manager) Has(command string) bool

Has indicates whether the specified command/alias is registered.

func (*Manager) OfferSuggestions

func (m *Manager) OfferSuggestions(ctx context.Context, source Source, cmdline string) ([]string, error)

OfferSuggestions returns completion suggestions.

func (*Manager) Parse

func (m *Manager) Parse(ctx context.Context, src Source, command string) *ParseResults

Parse stores a required command invoker Source in ctx, parses the command and returns parse results for use with Execute.

func (*Manager) ParseReader

func (m *Manager) ParseReader(ctx context.Context, src Source, command *brigodier.StringReader) *ParseResults

ParseReader stores a required command invoker Source in ctx, parses the command and returns parse results for use with Execute.

type ParseResults

type ParseResults brigodier.ParseResults

ParseResults are the parse results of a parsed command input.

It overlays brigodier.ParseResults to make clear that Manager.Execute must only get parse results returned by Manager.Parse.

type RequiresContext

type RequiresContext struct {
	context.Context
	Source
}

RequiresContext wraps the context for a brigodier.RequireFn.

type Source

type Source interface {
	permission.Subject
	// SendMessage sends a message component to the invoker.
	SendMessage(msg component.Component) error
}

Source is the invoker of a command. It could be a player or the console/terminal.

func SourceFromContext

func SourceFromContext(ctx context.Context) Source

SourceFromContext retrieves the Source from a command's context.

type SuggestFunc

type SuggestFunc func(
	c *Context,
	b *brigodier.SuggestionsBuilder) *brigodier.Suggestions

SuggestFunc is a convenient function type implementing the brigodier.SuggestionProvider interface.

Jump to

Keyboard shortcuts

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