cli

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MacroDir           = "macro"
	ConfigDir          = ".wsget"
	HistoryFilename    = ConfigDir + "/history"
	HistoryCmdFilename = ConfigDir + "/cmd_history"
	ConfigDirMode      = 0o755
	CommandsLimit      = 100
	HistoryLimit       = 100

	MacOSDeleteKey = 127

	HideCursor = "\x1b[?25l"
	ShowCursor = "\x1b[?25h"

	Bell = "\a"
)
View Source
const (
	LineUp         = "\x1b[1A"
	LineClear      = "\x1b[2K"
	NewLine        = '\n'
	ReturnCarriege = "\r"
	Backspace      = "\b"
)
View Source
const (
	PastingTimingThresholdInMicrosec = 250
	ErrInterrupted                   = "interrupted"
)
View Source
const (
	CommandPartsNumber = 2
)
View Source
const (
	HistoryFileRigths = 0o644
)
View Source
const (
	KeyboardBufferSize = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

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

func NewCLI

func NewCLI(wsConn *ws.Connection, input Inputer, output io.Writer) (*CLI, error)

func (*CLI) Run

func (c *CLI) Run(opts RunOptions) error

type CommandCmdEdit added in v0.3.0

type CommandCmdEdit struct{}

func NewCommandCmdEdit added in v0.3.0

func NewCommandCmdEdit() *CommandCmdEdit

func (*CommandCmdEdit) Execute added in v0.3.0

func (c *CommandCmdEdit) Execute(exCtx *ExecutionContext) (Executer, error)

type CommandEdit added in v0.3.0

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

func NewCommandEdit added in v0.3.0

func NewCommandEdit(content string) *CommandEdit

func (*CommandEdit) Execute added in v0.3.0

func (c *CommandEdit) Execute(exCtx *ExecutionContext) (Executer, error)

type CommandExit added in v0.3.0

type CommandExit struct{}

func NewCommandExit added in v0.3.0

func NewCommandExit() *CommandExit

func (*CommandExit) Execute added in v0.3.0

func (c *CommandExit) Execute(_ *ExecutionContext) (Executer, error)

type CommandPrintMsg added in v0.3.0

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

func NewCommandPrintMsg added in v0.3.0

func NewCommandPrintMsg(msg ws.Message) *CommandPrintMsg

func (*CommandPrintMsg) Execute added in v0.3.0

func (c *CommandPrintMsg) Execute(exCtx *ExecutionContext) (Executer, error)

type CommandSend added in v0.3.0

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

func NewCommandSend added in v0.3.0

func NewCommandSend(request string) *CommandSend

func (*CommandSend) Execute added in v0.3.0

func (c *CommandSend) Execute(exCtx *ExecutionContext) (Executer, error)

type CommandSequence added in v0.3.0

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

func NewCommandSequence added in v0.3.0

func NewCommandSequence(subCommands []Executer) *CommandSequence

func (*CommandSequence) Execute added in v0.3.0

func (c *CommandSequence) Execute(exCtx *ExecutionContext) (Executer, error)

type CommandWaitForResp added in v0.3.0

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

func NewCommandWaitForResp added in v0.3.0

func NewCommandWaitForResp(timeout time.Duration) *CommandWaitForResp

func (*CommandWaitForResp) Execute added in v0.3.0

func (c *CommandWaitForResp) Execute(exCtx *ExecutionContext) (Executer, error)

type Config added in v0.3.0

type Config struct {
	Version string              `yaml:"version"`
	Macro   map[string][]string `yaml:"macro"`
	Domains []string            `yaml:"domains"`
}

type Content added in v0.2.0

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

func NewContent added in v0.2.0

func NewContent() *Content

func (*Content) Clear added in v0.2.0

func (c *Content) Clear() string

func (*Content) GetLinesAfterPosition added in v0.2.0

func (c *Content) GetLinesAfterPosition(pos int) (startOfLine int, lines []string)

func (*Content) InsertSymbol added in v0.2.0

func (c *Content) InsertSymbol(symbol rune) string

func (*Content) MovePositionLeft added in v0.2.0

func (c *Content) MovePositionLeft() string

func (*Content) MovePositionRight added in v0.2.0

func (c *Content) MovePositionRight() string

func (*Content) MoveToEnd added in v0.2.0

func (c *Content) MoveToEnd() string

func (*Content) PrevSymbol added in v0.2.0

func (c *Content) PrevSymbol() rune

func (*Content) RemoveSymbol added in v0.2.0

func (c *Content) RemoveSymbol() string

func (*Content) ReplaceText added in v0.2.0

func (c *Content) ReplaceText(text string) string

func (*Content) String added in v0.2.0

func (c *Content) String() string

func (*Content) ToRequest added in v0.2.0

func (c *Content) ToRequest() string

type Editor added in v0.2.0

type Editor struct {
	History *History
	// contains filtered or unexported fields
}

func NewEditor added in v0.2.0

func NewEditor(output io.Writer, history *History, isSingleLine bool) *Editor

func (*Editor) EditRequest added in v0.2.0

func (ed *Editor) EditRequest(keyStream <-chan keyboard.KeyEvent, initBuffer string) (string, error)

type Executer added in v0.3.0

type Executer interface {
	Execute(*ExecutionContext) (Executer, error)
}

func CommandFactory added in v0.3.0

func CommandFactory(raw string, macro *Macro) (Executer, error)

type ExecutionContext added in v0.3.0

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

type History

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

func NewHistory

func NewHistory(fileName string, limit uint) *History

func (*History) AddRequest

func (h *History) AddRequest(request string)

func (*History) NextRequst added in v0.2.0

func (h *History) NextRequst() string

func (*History) PrevRequst added in v0.2.0

func (h *History) PrevRequst() string

func (*History) ResetPosition added in v0.2.0

func (h *History) ResetPosition()

func (*History) SaveToFile added in v0.1.2

func (h *History) SaveToFile() error

type Inputer added in v0.2.0

type Inputer interface {
	GetKeys() (<-chan keyboard.KeyEvent, error)
	Close()
}

type Keyboard added in v0.2.0

type Keyboard struct{}

func NewKeyboard added in v0.2.0

func NewKeyboard() *Keyboard

func (*Keyboard) Close added in v0.2.0

func (k *Keyboard) Close()

func (*Keyboard) GetKeys added in v0.2.0

func (k *Keyboard) GetKeys() (<-chan keyboard.KeyEvent, error)

type Macro added in v0.3.0

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

func LoadMacro added in v0.3.0

func LoadMacro(path string) (*Macro, error)

func LoadMacroForDomain added in v0.3.0

func LoadMacroForDomain(macroDir, domain string) (*Macro, error)

func NewMacro added in v0.3.0

func NewMacro(domains []string) *Macro

func (*Macro) AddCommands added in v0.3.0

func (m *Macro) AddCommands(name string, rawCommands []string) error

func (*Macro) Get added in v0.3.0

func (m *Macro) Get(name string) (Executer, error)

type RunOptions added in v0.2.0

type RunOptions struct {
	OutputFile *os.File
	Commands   []Executer
}

Jump to

Keyboard shortcuts

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