cli

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: GPL-2.0, GPL-2.0-or-later Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAmbiguous = errors.New("ambiguous")
	ParseError   = errors.New("parse error") // generic parse error
)
View Source
var Default = &Main{
	Prompt: "# ",
}
View Source
var ErrQuit = errors.New("")

Functions

func AddCommand

func AddCommand(c Commander)

func Exec

func Exec(w io.Writer, r io.Reader) error

func ExecInput

func ExecInput(w io.Writer, in *Input) error

Types

type Action

type Action func(c Commander, w Writer, in *Input) (err error)

type Command

type Command struct {
	// Command name separated by space; alias by commas.
	Name            string
	ShortHelp, Help string
	Action
}

func (*Command) CliAction

func (c *Command) CliAction(w Writer, in *Input) (err error)

func (*Command) CliHelp

func (c *Command) CliHelp() string

func (*Command) CliName

func (c *Command) CliName() string

func (*Command) CliShortHelp

func (c *Command) CliShortHelp() string

type Commander

type Commander interface {
	CliName() string
	CliAction(w Writer, in *Input) error
}

type File

type File struct {
	ServerConfig

	iomux.FileReadWriteCloser
	// contains filtered or unexported fields
}

func (*File) ReadReady

func (c *File) ReadReady() (err error)

func (*File) RxReady

func (c *File) RxReady() (err error)

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

func (*File) WriteReady

func (c *File) WriteReady() (err error)

type FilePool

type FilePool struct {
	elib.Pool
	Files []File
}

func (*FilePool) Elts

func (p *FilePool) Elts() uint

func (*FilePool) Foreach

func (p *FilePool) Foreach(f func(x File))

func (*FilePool) ForeachIndex

func (p *FilePool) ForeachIndex(f func(i uint))

func (*FilePool) GetIndex

func (p *FilePool) GetIndex() (i uint)

func (*FilePool) IsFree

func (p *FilePool) IsFree(i uint) (v bool)

func (*FilePool) Len

func (p *FilePool) Len() uint

func (*FilePool) PutIndex

func (p *FilePool) PutIndex(i uint) (ok bool)

func (*FilePool) Reset

func (p *FilePool) Reset()

func (*FilePool) Resize

func (p *FilePool) Resize(n uint)

func (*FilePool) Validate

func (p *FilePool) Validate(i uint)

type Helper

type Helper interface {
	CliHelp() string
}

type Input

type Input struct{ parse.Input }

type LoopStarter

type LoopStarter interface {
	CliLoopStart(m *Main)
}

type Main

type Main struct {
	Prompt  string
	RxReady func(c *File)
	FilePool
	// contains filtered or unexported fields
}

func (*Main) Add

func (c *Main) Add(name string, action Action)

func (*Main) AddCommand

func (m *Main) AddCommand(C Commander)

func (*Main) AddFile

func (c *Main) AddFile(f iomux.FileReadWriteCloser, cf ServerConfig)

func (*Main) AddServer

func (c *Main) AddServer(config string, cf ServerConfig) (s *Server, err error)

func (*Main) AddStdin

func (c *Main) AddStdin()

func (*Main) End

func (c *Main) End()

func (*Main) Exec

func (m *Main) Exec(w io.Writer, r io.Reader) error

func (*Main) ExecInput

func (m *Main) ExecInput(w io.Writer, in *Input) (err error)

func (*Main) Exit

func (c *Main) Exit()

func (*Main) Loop

func (c *Main) Loop()

func (*Main) Start

func (m *Main) Start()

func (*Main) Write

func (m *Main) Write(p []byte) (n int, err error)

type Server

type Server struct {
	ServerConfig
	socket.Server
	// contains filtered or unexported fields
}

func (*Server) Elts

func (p *Server) Elts() uint

func (*Server) Foreach

func (p *Server) Foreach(f func(x client))

func (*Server) ForeachIndex

func (p *Server) ForeachIndex(f func(i uint))

func (*Server) GetIndex

func (p *Server) GetIndex() (i uint)

func (*Server) IsFree

func (p *Server) IsFree(i uint) (v bool)

func (*Server) Len

func (p *Server) Len() uint

func (*Server) PutIndex

func (p *Server) PutIndex(i uint) (ok bool)

func (*Server) ReadReady

func (s *Server) ReadReady() (err error)

func (*Server) Reset

func (p *Server) Reset()

func (*Server) Resize

func (p *Server) Resize(n uint)

func (*Server) Validate

func (p *Server) Validate(i uint)

type ServerConfig

type ServerConfig struct {
	DisablePrompt bool
	EnableQuit    bool
}

type ShortHelper

type ShortHelper interface {
	CliShortHelp() string
}

type Writer

type Writer interface {
	io.Writer
}

Jump to

Keyboard shortcuts

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