command

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdType

type CmdType int

CmdType is a type of default command

const (
	OtherCmd CmdType = iota
	OpenCmd
	CloseCmd
	BufferCmd
	LinkCmd
	QuitCmd
	ReloadCmd
	RestartCmd
)

Currently supported cmdtypes

type Command

type Command struct {
	// The sending client ID
	UUID    uint32
	CmdType CmdType
	// Arguments for known commands, such as buffer/open/close/link
	Args []string
	// The active buffer of the client who sent the command
	From string
}

Command is a ctl message

func FromBytes

func FromBytes(uuid uint32, from string, b []byte) (*Command, error)

FromBytes returns a command from byte input, or an error if it was unable to parse

func FromString

func FromString(uuid uint32, from, s string) (*Command, error)

FromString retruns a command from string input, or an error if it was unable to parse

cmdChannel <- FromString(clientuuid, "buffer newbuffer")
cmdChannel <- FromString(clientuuid, "link new old")

func New

func New(uuid uint32, cmdType CmdType, from string, args ...string) *Command

New - helper func with varargs If there are 2 args, the first is assumed to be the "From" path, the second "Args" If only one, it is set as "Args"

cmdChannel <- New(clientuuid, BufferCmd, "somebuffer", "newbuffer")
cmdChannel <- New(clientuuid, CloseCmd, "somebuffer", "oldbuffer")
cmdChannel <- New(clientuuid, LinkCmd, "oldbuffer", "newbuffer")

func (*Command) WriteOut

func (c *Command) WriteOut(w io.Writer) error

WriteOut will write the command correctly to the Writer If a command is poorly formatted, it will return an error

Jump to

Keyboard shortcuts

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