help

package
v0.0.0-...-aecff93 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidArgType = errors.New("invalid argument type")
)

Functions

func GetHelps

func GetHelps() map[string]*Help

returns a copy of the map containing all Help structs does NOT copy Help structs themselves entries in the map can be nil

func RegisterHelp

func RegisterHelp(name string, help *Help)

RegisterHelp registers a Help struct to global map if help.Name is empty it is set to name

Types

type ArgType

type ArgType uint8
const (
	ArgAny    ArgType = iota //any
	ArgInt                   //int
	ArgUInt                  //uint
	ArgBool                  //bool
	ArgPos                   //pos
	ArgString                //string
)

func (ArgType) String

func (i ArgType) String() string

type Argument

type Argument struct {
	Name string
	Type ArgType
}

Argument defines a argument to a chatcommand

func MustParseArgs

func MustParseArgs(args string) []Argument

Wraps ParseArgs; panics if error is encountered

func ParseArg

func ParseArg(arg string) (Argument, error)

ParseArg tries to parse a argument from string Syntax is <type>:<name> split at first colon; if no type is specified ArgAny is used

func ParseArgs

func ParseArgs(args string) ([]Argument, error)

ParseArgs tries to parse a space seperated list of arguments Syntax is same used by ParseArg

type Help

type Help struct {
	Name string
	Desc string

	Args []Argument
}

Help defines the help given for a give chatcommand

func GetHelp

func GetHelp(name string) *Help

Jump to

Keyboard shortcuts

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