commands

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAndExecuteSBCommand

func BuildAndExecuteSBCommand(log *models.Log, user *models.User, args ...string) (err error)

BuildAndExecuteSBCommand builds the command

func BuildSBCommand

func BuildSBCommand(log *models.Log, user *models.User, args ...string) (bc Command, ct *Context, err error)

BuildSBCommand builds the command

func DisplayHelpers

func DisplayHelpers(helpers helpers.Helper, arguments map[string]Argument)

DisplayHelpers displays the helper for a command

func GetCommands

func GetCommands() map[string]Factory

func IsAPublicCommand

func IsAPublicCommand(command string) bool

IsAPublicCommand returns true if the argument passed is a public trusted command

func IsReplicableCommand

func IsReplicableCommand(command string) bool

func RegisterCommand

func RegisterCommand(name string, command Factory)

Types

type Argument

type Argument struct {
	Required      bool
	Description   string
	AllowedValues []string
	DefaultValue  string
	Type          ArgumentType
}

Argument describes the basic properties of a sb command argument

type ArgumentType

type ArgumentType int32

ArgumentType describes the type of the argument

const (
	STRING ArgumentType = iota
	BOOL
)

type Command

type Command interface {
	Checks(ct *Context) error
	Execute(ct *Context) (models.ReplicationData, error, error)
	PostExecute(repl models.ReplicationData) error
	Replicate(repl models.ReplicationData) error
}

Command descibes the required functions of a sb command interface

func GetCommand

func GetCommand(commandName string) (cmd Command, rights models.Right, helpers helpers.Helper, args map[string]Argument, err error)

type Context

type Context struct {
	User               *models.User
	Log                *models.Log
	Group              *models.Group
	AI                 *models.Info
	BA                 *models.Access
	FormattedArguments map[string]string
	RawArguments       []string
}

type Factory

type Factory func() (c Command, r models.Right, h helpers.Helper, args map[string]Argument)

Factory describes the command factory that registers the commands

Jump to

Keyboard shortcuts

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