cshell

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 5 Imported by: 0

README

cshell

A go package implementing a simple command line shell

Documentation

Index

Constants

View Source
const (
	VT100_UP    = 65
	VT100_DOWN  = 66
	VT100_RIGHT = 67
	VT100_LEFT  = 68
	ASCII_TAB   = 0x09
	ASCII_CTRLC = 0x03
	ASCII_CTRLD = 0x04
	ASCII_BEL   = 0x07
	ASCII_BS    = 0x08
	ASCII_CR    = 0x0D
	ASCII_LF    = 0x0A
	ASCII_ESC   = 0x1B
	ASCII_DEL   = 0x7F
)

Variables

This section is empty.

Functions

func ParseLine added in v1.0.2

func ParseLine(line string) (args []string, err error)

Types

type Command

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

type CommandFunc

type CommandFunc = func(args []string) error

type Shell

type Shell struct {
	Prompt string
	Echo   bool
	// contains filtered or unexported fields
}

func New

func New() (s *Shell)

New creates a new command prompt.

func (*Shell) Command

func (s *Shell) Command(name string, desc string, fx CommandFunc)

func (*Shell) Help

func (s *Shell) Help(args []string) error

func (*Shell) HexDump

func (s *Shell) HexDump(buf []byte)

HexDump outputs a `hexdump -C` like dump of the buf argument

func (*Shell) Print

func (s *Shell) Print(v ...interface{})

Print sends output to the configured io.Writer Arguments are handled in the manner of fmt.Print.

func (*Shell) Printf

func (s *Shell) Printf(format string, v ...interface{})

Printf sends output to the configured io.Writer Arguments are handled in the manner of fmt.Printf.

func (*Shell) Println

func (s *Shell) Println(v ...interface{})

Println sends output to the configured io.Writer Arguments are handled in the manner of fmt.Println.

func (*Shell) Run

func (s *Shell) Run()

Run reads and writes from the io streams generating the command prompt and executing commands.

func (*Shell) SetEcho

func (s *Shell) SetEcho(echo bool)

SetEcho changes the echo state for the command prompt.

func (*Shell) SetIO

func (s *Shell) SetIO(r io.Reader, w io.Writer)

SetIO assigns input and output sources. They should conform to the io.Reader and io.Writer interface. The io.Reader should block until a characters are ready.

func (*Shell) SetPrompt

func (s *Shell) SetPrompt(prompt string)

SetPrompt changes the shell command prompt.

Directories

Path Synopsis
examples
sshd command
telnetd command
term command

Jump to

Keyboard shortcuts

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