Documentation
¶
Overview ¶
Package slashcommands provides recipe-backed slash command parsing and expansion.
Index ¶
- func AvailableRecipeNames(ctx context.Context, processor *fragments.Processor) string
- func BuildCommandHint(arguments map[string]fragments.ArgumentMeta) string
- func BuildCommandPlaceholder(command string, arguments map[string]fragments.ArgumentMeta) string
- func BuildDisplay(command, args string) string
- func Parse(text string) (command string, args string, found bool)
- func ParseArgs(args string) (kvArgs map[string]string, additionalText string)
- type Command
- type Expansion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AvailableRecipeNames ¶
AvailableRecipeNames returns a comma-separated list of available recipe names.
func BuildCommandHint ¶
func BuildCommandHint(arguments map[string]fragments.ArgumentMeta) string
BuildCommandHint builds a hint string for a recipe based on its arguments.
func BuildCommandPlaceholder ¶
func BuildCommandPlaceholder(command string, arguments map[string]fragments.ArgumentMeta) string
BuildCommandPlaceholder builds an example slash invocation for composer placeholders.
func BuildDisplay ¶
BuildDisplay returns the compact user-facing slash invocation.
func Parse ¶
Parse parses a slash command from text. The command name is everything after the leading slash up to the first space. Names may contain slashes.
func ParseArgs ¶
ParseArgs parses key=value pairs and additional text from an arguments string.
Grammar:
args = *(key_value / word) [additional_text] key_value = key "=" value key = 1*non_space_non_eq value = quoted_value / unquoted_value quoted_value = DQUOTE *non_dquote DQUOTE unquoted_value = *non_space word = 1*non_space (collected as additional_text)
Types ¶
type Command ¶
type Command struct {
Name string `json:"name"`
Description string `json:"description"`
Hint string `json:"hint,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
}
Command describes an available slash command backed by a recipe.