cli

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 10 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 (
	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.ConnectionHandler, input Inputer, output io.Writer) (*CLI, error)

NewCLI creates a new CLI instance with the given wsConn, input, and output. It returns an error if it fails to get the current user, create the necessary directories, load the macro for the domain, or initialize the CLI instance.

func (*CLI) Run

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

Run runs the CLI with the provided options. It listens for user input and executes commands accordingly.

type ConnectionHandler added in v0.3.1

type ConnectionHandler interface {
	Messages() <-chan ws.Message
	Hostname() string
	Send(msg string) (*ws.Message, error)
	Close()
}

type ExecutionContext added in v0.3.0

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

func NewExecutionContext added in v0.3.1

func NewExecutionContext(cli *CLI, input <-chan keyboard.KeyEvent, outputFile io.Writer) *ExecutionContext

func (*ExecutionContext) CmdEditor added in v0.3.1

func (ctx *ExecutionContext) CmdEditor() command.Editor

func (*ExecutionContext) Connection added in v0.3.1

func (ctx *ExecutionContext) Connection() ws.ConnectionHandler

func (*ExecutionContext) Formater added in v0.3.1

func (ctx *ExecutionContext) Formater() formater.Formater

func (*ExecutionContext) Input added in v0.3.1

func (ctx *ExecutionContext) Input() <-chan keyboard.KeyEvent

func (*ExecutionContext) Macro added in v0.3.1

func (ctx *ExecutionContext) Macro() *command.Macro

func (*ExecutionContext) Output added in v0.3.1

func (ctx *ExecutionContext) Output() io.Writer

func (*ExecutionContext) OutputFile added in v0.3.1

func (ctx *ExecutionContext) OutputFile() io.Writer

func (*ExecutionContext) RequestEditor added in v0.3.1

func (ctx *ExecutionContext) RequestEditor() command.Editor

type Formater added in v0.3.1

type Formater interface {
	FormatMessage(wsMsg ws.Message) (string, error)
	FormatForFile(wsMsg ws.Message) (string, 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 RunOptions added in v0.2.0

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

Jump to

Keyboard shortcuts

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