cli

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Parser = reflector.Parser[string]{}
)

Functions

func InputProc

func InputProc(str string) []string

Types

type CloseReq

type CloseReq struct{}

type CloseResp

type CloseResp struct{}

type Commander

type Commander interface {
	Commands() *handler.Commands
	EC() *ExitClose
}

type Context

type Context interface {
	io.Writer
	io.Reader
	WriteString(str string) (int, error)
	WriteStrings(strs ...string) (int, error)
	ReadString(cancel <-chan bool) string
	Input(prompt string, v any) bool
	PopulateStruct(cmd string, s any) bool
	Parser() reflector.Parser[string]
}

func NewContext

func NewContext(w io.Writer, in <-chan []byte, parser reflector.Parser[string]) Context

type ExitClose

type ExitClose struct {
	Exit, Close       bool
	CanExit, CanClose bool
	OnExit, OnClose   func()
}

func NewExitClose

func NewExitClose(onExit, onClose func()) *ExitClose

func (*ExitClose) Commands

func (ec *ExitClose) Commands() *ExitCloseHandler

func (*ExitClose) EC

func (ec *ExitClose) EC() *ExitClose

type ExitCloseHandler

type ExitCloseHandler struct {
	*ExitClose
	CloseDesc, ExitDesc string
}

func (*ExitCloseHandler) CloseHandler

func (ech *ExitCloseHandler) CloseHandler(e *CloseReq) *CloseResp

func (*ExitCloseHandler) CloseUsage

func (ech *ExitCloseHandler) CloseUsage() *handler.CommandDetails

func (*ExitCloseHandler) ExitHandler

func (ech *ExitCloseHandler) ExitHandler(e *ExitReq) *ExitResp

func (*ExitCloseHandler) ExitUsage

func (ech *ExitCloseHandler) ExitUsage() *handler.CommandDetails

type ExitReq

type ExitReq struct{}

type ExitResp

type ExitResp struct{}

type HandlerLister

type HandlerLister interface {
	Handlers(*Runner) []any
}

type HelpReq

type HelpReq struct {
	Command []string
}

func (*HelpReq) Init

func (h *HelpReq) Init(input []string)

type HelpResp

type HelpResp struct {
	Command []string
}

type Helper

type Helper string

func (Helper) HelpHandler

func (Helper) HelpHandler(req *HelpReq) *HelpResp

func (Helper) HelpUsage

func (h Helper) HelpUsage() *handler.CommandDetails

type Initer

type Initer interface {
	Init(input []string)
}

type Runner

type Runner struct {
	*handler.Commands
	*ExitClose
	Context
	RespHandler  *handler.Switch
	Timeout      int
	Prompt       string
	InputProc    func(string) []string
	StartMessage string
}

func NewRunner

func NewRunner(c Commander) *Runner

func (*Runner) CloseRespHandler

func (r *Runner) CloseRespHandler(c *CloseResp)

func (*Runner) ExitRespHandler

func (r *Runner) ExitRespHandler(e *ExitResp)

func (*Runner) HelpRespHandler

func (r *Runner) HelpRespHandler(resp *HelpResp)

func (*Runner) Run

func (r *Runner) Run()

func (*Runner) ShowCommands

func (r *Runner) ShowCommands(path []string)

func (*Runner) Static

func (r *Runner) Static(input []string)

Jump to

Keyboard shortcuts

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