Help us shape the future of Go! Take the 2026 Go Developer Survey

shell

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TTClose   = iota // Should be closed
	TTRunning        // Currently running a command
	TTDone           // Finished running a command
)

Variables

View Source
var CloseTerms chan bool
View Source
var Jobs chan JobFunction

Functions

func ExecCommand

func ExecCommand(name string, arg ...string) (string, error)

ExecCommand executes a command using exec It returns any output/errors

func JobSend

func JobSend(j *Job, data string)

JobSend sends the given data into the job's stdin stream

func JobStop

func JobStop(j *Job)

JobStop kills a job

func RunBackgroundShell

func RunBackgroundShell(input string) (func() string, error)

RunBackgroundShell runs a shell command in the background It returns a function which will run the command and returns a string message result

func RunCommand

func RunCommand(input string) (string, error)

RunCommand executes a shell command and returns the output/error

func RunInteractiveShell

func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error)

RunInteractiveShell runs a shellcommand interactively

Types

type CallbackFile

type CallbackFile struct {
	io.Writer
	// contains filtered or unexported fields
}

A CallbackFile is the data structure that makes it possible to catch stderr and stdout write events

func (*CallbackFile) Write

func (f *CallbackFile) Write(data []byte) (int, error)

type CallbackFunc

type CallbackFunc func(string)

type Job

type Job struct {
	*exec.Cmd
	Stdin io.WriteCloser
}

Job stores the executing command for the job, and the stdin pipe

func JobSpawn

func JobSpawn(cmdName string, cmdArgs []string, onStdout, onStderr, onExit func(string, []interface{}), userargs ...interface{}) *Job

JobSpawn starts a process with args in the background with the given callbacks It returns an *exec.Cmd as the job id

func JobStart

func JobStart(cmd string, onStdout, onStderr, onExit func(string, []interface{}), userargs ...interface{}) *Job

JobStart starts a shell command in the background with the given callbacks It returns an *exec.Cmd as the job id

type JobFunction

type JobFunction struct {
	Function func(string, []interface{})
	Output   string
	Args     []interface{}
}

JobFunction is a representation of a job (this data structure is what is loaded into the jobs channel)

type TermType

type TermType int

type Terminal

type Terminal struct {
	State terminal.State
	Term  *terminal.VT

	Status    TermType
	Selection [2]buffer.Loc
	// contains filtered or unexported fields
}

A Terminal holds information for the terminal emulator

func (*Terminal) Close

func (t *Terminal) Close()

Close sets the Status to TTClose indicating that the terminal is done and should be closed

func (*Terminal) GetSelection

func (t *Terminal) GetSelection(width int) string

GetSelection returns the selected text

func (*Terminal) HasSelection

func (t *Terminal) HasSelection() bool

HasSelection returns whether this terminal has a valid selection

func (*Terminal) Name

func (t *Terminal) Name() string

func (*Terminal) Start

func (t *Terminal) Start(execCmd []string, getOutput bool, wait bool, callback func(out string, userargs []interface{}), userargs []interface{}) error

Start begins a new command in this terminal with a given view

func (*Terminal) Stop

func (t *Terminal) Stop()

Stop stops execution of the terminal and sets the Status to TTDone

func (*Terminal) WriteString

func (t *Terminal) WriteString(str string)

WriteString writes a given string to this terminal's pty

Jump to

Keyboard shortcuts

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