Documentation ¶
Overview ¶
Package slashparse is a parser for slash commands.
Index ¶
- func GetPositionalArgs(argString string) []string
- type Argument
- type SlashCommand
- func (s *SlashCommand) Execute(slashString string) (string, error)
- func (s *SlashCommand) GetSlashHelp() string
- func (s *SlashCommand) Parse(slashString string) (string, map[string]string, error)
- func (s *SlashCommand) SetHandler(commandString string, handler func(map[string]string) (string, error)) error
- type SubCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPositionalArgs ¶
GetPositionalArgs takes a string of arguments and splits it up by spaces and double quotes
Types ¶
type Argument ¶
type Argument struct { Name string `yaml:"name" json:"name"` ArgType string `yaml:"argtype" json:"argtype"` Description string `yaml:"description" json:"description"` ErrorMsg string `yaml:"errorMsg" json:"errorMsg"` Position int `yaml:"position" json:"position"` Required bool `yaml:"required" json:"required"` }
Argument defines and argument in a slash command
type SlashCommand ¶
type SlashCommand struct { Name string `yaml:"name" json:"name,omitempty"` Description string `yaml:"description" json:"description"` Arguments []Argument `yaml:"arguments" json:"arguments,omitempty"` SubCommands []SubCommand `yaml:"subcommands" json:"subcommands"` }
SlashCommand defines the structure of a slash command string
func NewSlashCommand ¶
func NewSlashCommand(slashDef []byte) (s SlashCommand, err error)
NewSlashCommand define a new slash command to parse
func (*SlashCommand) Execute ¶
func (s *SlashCommand) Execute(slashString string) (string, error)
Execute parses and runs the configured handler to process your command.
func (*SlashCommand) GetSlashHelp ¶
func (s *SlashCommand) GetSlashHelp() string
GetSlashHelp returns a markdown formated help for a slash command
func (*SlashCommand) SetHandler ¶
func (s *SlashCommand) SetHandler(commandString string, handler func(map[string]string) (string, error)) error
SetHandler sets the function that should be called based on the set of slash command and subcommands
type SubCommand ¶
type SubCommand struct { Name string `yaml:"name" json:"name"` Description string `yaml:"description" json:"description"` Arguments []Argument `yaml:"arguments" json:"arguments"` SubCommands []SubCommand `yaml:"subcommands" json:"subcommands"` // contains filtered or unexported fields }
SubCommand defines a command that proceeded the slash command
Click to show internal directories.
Click to hide internal directories.