console

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 10 Imported by: 1

README

Console

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCmdNoHandler = errors.New("command has no handler")
)
View Source
var StyleError = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#FF4672", Dark: "#FF4672"})

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	Name                 string
	Aliases              []string
	Description          string
	IgnorePipe           bool
	Matcher              func(cmd string) bool
	IgnoreDefaultMatcher bool
	Handler              func(c *Console, args []string) error
	Console              *Console
}

func (*Cmd) Handle

func (c *Cmd) Handle(cmd string) error

func (*Cmd) Match

func (c *Cmd) Match(cmd string) bool

type Console

type Console struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Opts) (*Console, error)

func (*Console) Close

func (c *Console) Close() error

func (*Console) Ctx added in v0.2.1

func (c *Console) Ctx() context.Context

func (*Console) ExitCmd

func (c *Console) ExitCmd() (*Cmd, bool)

func (*Console) RegisterCommands

func (c *Console) RegisterCommands(cmds ...*Cmd) error

func (*Console) Start

func (c *Console) Start() error

type Opts

type Opts func(*Console)

func WithContext

func WithContext(ctx context.Context) Opts

func WithDynamicPrompt added in v0.2.0

func WithDynamicPrompt(promtC <-chan string) Opts

func WithExitCmd

func WithExitCmd(e *Cmd) Opts

func WithHandleCtrlC

func WithHandleCtrlC(handle bool) Opts

func WithHistoryFile

func WithHistoryFile(file string) Opts

func WithPrompt added in v0.2.0

func WithPrompt(prompt string) Opts

func WithWelcomeMsg

func WithWelcomeMsg(msg string) Opts

Directories

Path Synopsis
example
echo Module

Jump to

Keyboard shortcuts

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