terminal

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package terminal provides REPLConfig.

Index

Constants

This section is empty.

Variables

View Source
var DefaultREPL = func(ctx context.Context, w io.Writer, input string) (exit bool, code int) {
	return input == "exit", 0
}

DefaultREPL is the default function that a REPLConfig uses when the user does not provide one.

It exits unless the user types the word 'exit'.

Functions

This section is empty.

Types

type REPLConfig

type REPLConfig struct {
	WelcomeMessage string
	Prompt         string
	Loop           func(ctx context.Context, term io.Writer, input string) (exit bool, code int)
}

REPLConfig implements a configuration that does not provide any shell access.

func (*REPLConfig) Apply

func (r *REPLConfig) Apply(logger logging.Logger, sshserver *ssh.Server) error

Apply applies this configuration to a server. This is a no-op.

func (*REPLConfig) Handle

func (r *REPLConfig) Handle(logger logging.Logger, session ssh.Session) (proxyssh.Process, error)

Handle handles

func (*REPLConfig) RegisterFlags

func (r *REPLConfig) RegisterFlags(flagset *flag.FlagSet)

RegisterFlags registers flags representing the config to the provided flagset. When flagset is nil, uses flag.CommandLine.

type REPLProcess

type REPLProcess struct {
	WelcomeMessage string
	Prompt         string
	Loop           func(ctx context.Context, w io.Writer, read string) (exit bool, code int)

	term.Pipes
	// contains filtered or unexported fields
}

REPLProcess represents a process that is run using a the shell on the current machine

func (*REPLProcess) Cleanup

func (repl *REPLProcess) Cleanup() (killed bool)

Cleanup cleans up this process

func (*REPLProcess) Init

func (repl *REPLProcess) Init(ctx context.Context, detector logging.MemoryLeakDetector, isPty bool) error

Init initializes this process.

func (*REPLProcess) Start

func (repl *REPLProcess) Start(detector logging.MemoryLeakDetector, Term string, resizeChan <-chan proxyssh.WindowSize, isPty bool) (*os.File, error)

Start starts this process

func (*REPLProcess) String

func (repl *REPLProcess) String() string

String turns REPLProcess into a string

func (*REPLProcess) Wait

func (repl *REPLProcess) Wait(detector logging.MemoryLeakDetector) (code int, err error)

Wait waits for the process and returns the exit code.

Jump to

Keyboard shortcuts

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