gommandparser

package module
v0.0.0-...-2fbbbd9 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 4 Imported by: 1

README

gommandparser

Coming soon

  • A README.md
  • Documentation of source
  • Support of flags (e.g.: --flag

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorWithoutPrefixNotAllowed = errors.New("no prefix is not allowed")
	ErrorEmptyLabelNotAllowed    = errors.New("empty label is not allowed")
)

Functions

func Use

func Use(options Options)

Types

type Command

type Command interface {
	Labels() []string
	Self() interface{}
}

type Message

type Message string

func (Message) Trim

func (msg Message) Trim() Message

type Options

type Options struct {
	Prefixes               []string  `json:"prefixes,omitempty"`
	Commands               []Command `json:"commands,omitempty"`
	ContinueWithoutPrefix  bool      `json:"continueWithoutPrefix,omitempty"`
	ContinueWithEmptyLabel bool      `json:"continueWithEmptyLabel,omitempty"`
	PrefixCaseSensitive    bool      `json:"prefixCaseSensitive,omitempty"`
	LabelCaseSensitive     bool      `json:"labelCaseSensitive,omitempty"`
}

type Parser

type Parser interface {
	Options() Options
	Use(options Options)
	Parse(message Message) (Result, error)
	ParseWithOptions(message Message, options Options) (Result, error)
}

func NewParser

func NewParser(options Options) Parser

type Result

type Result struct {
	Message           Message   `json:"message"`
	TrimmedMessage    Message   `json:"trim"`
	Prefixes          []string  `json:"prefixes"`
	Prefix            string    `json:"prefix"`
	MessageStrip      Message   `json:"messageStrip"`
	MessageStripSplit []string  `json:"messageStripSplit"`
	Label             string    `json:"label"`
	MessageCut        Message   `json:"messageCut"`
	Args              []string  `json:"args"`
	Matches           []Command `json:"matches"`
	Match             Command   `json:"match"`
}

func Parse

func Parse(message Message) (Result, error)

func ParseWithOptions

func ParseWithOptions(message Message, options Options) (Result, error)

func (Result) HasMatch

func (result Result) HasMatch() bool

Jump to

Keyboard shortcuts

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