commands

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Overview

Package commands provides command handling capable of ingesting transport.Events and responding over the provided transport wire. If the userDB is set permissions on a command will be honored otherwise if no userDB is set permissions will be ignored entirely (this could possibly use improvement).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Use     string
	Aliases []string
	Short   string
	Long    string

	ExecFunc func(ev *transport.Event) error

	Perms    []string
	Disabled bool
	Hidden   bool

	UserDB users.DB
	// contains filtered or unexported fields
}

Command is the base for all commands.

func (*Command) AddCommand

func (c *Command) AddCommand(cmd *Command)

AddCommand adds a new Command to the current command as a child.

func (*Command) Children

func (c *Command) Children() []*Command

Children returns the children commands if there are any.

func (*Command) Execute

func (c *Command) Execute(ev *transport.Event) error

Execute executes the command using the provided event. It attempts to match the event against any children commands first allowing a base Command to act as a command tree.

func (*Command) Parent

func (c *Command) Parent() *Command

Parent returns the parent command if there is one.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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