commander

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCommands = []*Command{
	{
		Name:        "open",
		Args:        []string{"<buffer>"},
		Heading:     DefaultGroup,
		Description: "Open and change buffers to a given service",
	},
	{
		Name:        "close",
		Args:        []string{"<buffer>"},
		Heading:     DefaultGroup,
		Description: "Close a buffer and return to the last opened previously",
	},
	{
		Name:        "buffer",
		Args:        []string{"<buffer>"},
		Heading:     DefaultGroup,
		Description: "Change to the named buffer",
	},
	{
		Name:        "link",
		Args:        []string{"<current>", "<buffer>"},
		Heading:     DefaultGroup,
		Description: "Overwrite the current buffer with the named",
	},
	{
		Name:        "quit",
		Args:        []string{},
		Heading:     DefaultGroup,
		Description: "Exits the client",
	},
}

TODO(halfiwt) i18n

Functions

This section is empty.

Types

type CmdList

type CmdList []*Command

Allow sorting of our lists

func (CmdList) Len

func (a CmdList) Len() int

func (CmdList) Less

func (a CmdList) Less(i, j int) bool

func (CmdList) Swap

func (a CmdList) Swap(i, j int)

type ComGroup

type ComGroup int

ComGroup is a logical grouping of commands To add a ComGroup, please do so in a PR

const (
	DefaultGroup ComGroup = iota
	ActionGroup
	MediaGroup
	ServiceGroup
)

Currently supported ComGroups

type Command

type Command struct {
	Name        string
	Description string
	Heading     ComGroup
	Args        []string
	Alias       []string
	From        string
	Sender      callback.Sender
}

Command represents an available command to a service The From field should generally be populated, except in the case of a ServiceGroup command

func (*Command) Bytes

func (c *Command) Bytes() []byte

Bytes - Return a byte representation of a command

func (*Command) String

func (c *Command) String() string

type Commander

type Commander interface {
	CtrlData() func() []byte
	// Exec will issue the given Command, and return any errors encountered
	Exec(*Command) error
	FindCommands(b []byte) ([]*Command, error)
	FromString(string) (*Command, error)
	FromBytes([]byte) (*Command, error)
	FindCommand(string, []*Command) (*Command, error)
	WriteCommands([]*Command, io.Writer) error
}

Jump to

Keyboard shortcuts

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