unixsocket

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(ctx cli.Context) error

func ConnPipe

func ConnPipe(conn net.Conn) channel.Pipe[[]byte]

Types

type Command

type Command struct {
	Name   string
	Action func(*Context)
	Usage  string
}

Command that a socket can accept.

type Commands

type Commands struct {
	Addr     string
	Name     string
	Commands []Command

	StartMessage string
	// contains filtered or unexported fields
}

Commands is used to setup and run the server side of a unix socket connection.

func (*Commands) Close

func (c *Commands) Close()

Close the underlying socket

func (*Commands) Help

func (c *Commands) Help() string

Help returns a description of all the registered commands as a string.

func (*Commands) Run

func (c *Commands) Run() error

Run the underlying socket

type Context

type Context struct {
	Socket *Commands

	Args []string
	// contains filtered or unexported fields
}

Context is passed into a Command

func (*Context) Close

func (c *Context) Close()

Close will cause the client end of the socket to close

func (*Context) Error

func (c *Context) Error(err error) bool

Error will print an error if there is one. Returns a bool indicating if there was an error.

func (*Context) Input

func (c *Context) Input(prompt string, v interface{}) bool

Input provides a prompt and populates a value. Currently supports string or int.

func (*Context) PopulateStruct

func (c *Context) PopulateStruct(cmd string, s interface{}) bool

PopulateStruct will provide a prompt for each field

func (*Context) Printf

func (c *Context) Printf(format string, a ...interface{}) (int, error)

Printf wraps fmt.Printf

func (*Context) Read

func (c *Context) Read() string

Read a line from the socket connection

func (*Context) String

func (c *Context) String() string

String is what was passed into the Command

func (*Context) Write

func (c *Context) Write(b []byte) (int, error)

Write to socket

func (*Context) WriteString

func (c *Context) WriteString(str string) (int, error)

WriteString to socket

type RunnerInitilizer

type RunnerInitilizer func(*cli.Runner)

type Socket

type Socket struct {
	Addr    string
	Handler func(conn net.Conn)
	// contains filtered or unexported fields
}

func New

func New(addr string, handler func(conn net.Conn)) *Socket

func (*Socket) Close

func (s *Socket) Close()

Close a running socket.

func (*Socket) Run

func (s *Socket) Run() error

Run the socket

func (*Socket) Runner

func (s *Socket) Runner(ri RunnerInitilizer) *Socket

Jump to

Keyboard shortcuts

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