silent

package
v0.0.0-...-537aa2f Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Verbose bool
)

Functions

This section is empty.

Types

type Expectation

type Expectation struct {
	Input  string `json:"input"`
	Output string `json:"output"`
}

Expectation is a structure that stores expected input and output coming from and to another application

type SilentCmd

type SilentCmd struct {
	Cmd           *exec.Cmd
	CmdString     string         `json:"cmd"`
	Expectations  []*Expectation `json:"expectations"`
	ReceiveBuffer *bytes.Buffer
	ReadChan      chan string
	ErrChan       chan error
	ErrStringChan chan string
	// contains filtered or unexported fields
}

SilentCmd is a command that will run silently this can be a regular command or it can be one that expects input from the user

func NewSilentCmd

func NewSilentCmd() *SilentCmd

NewSilentCmd returns a new SilentCmd with all of its fields initialized (except expected cases)

func (*SilentCmd) Exec

func (s *SilentCmd) Exec() error

Exec executes this SilentCmd, blocking until EOF

func (*SilentCmd) ExecTemplate

func (s *SilentCmd) ExecTemplate(m map[string]string) error

ExecTemplate parses a map replacing templated values in the command string

func (*SilentCmd) Init

func (s *SilentCmd) Init()

Init initializes this command's nil fields

func (*SilentCmd) Match

func (s *SilentCmd) Match(bufferString string) (match bool, expectation *Expectation)

Match checks the buffer string against expected cases, removing from the list when one is found

func (*SilentCmd) Pipes

func (s *SilentCmd) Pipes() (i io.WriteCloser, o io.ReadCloser, e io.ReadCloser, err error)

Pipes returns stdin, stdout, and stderr of this command

func (*SilentCmd) Read

func (s *SilentCmd) Read(reader io.Reader)

Read reads data from reader into s.ReadChan

func (*SilentCmd) ReadErr

func (s *SilentCmd) ReadErr(reader io.Reader)

ReadErr reads data from reader into s.ErrStringChan

func (*SilentCmd) ReadToChannel

func (s *SilentCmd) ReadToChannel(reader io.Reader, ch chan string)

ReadToChannel reads from reader to the channel ch

func (*SilentCmd) Receive

func (s *SilentCmd) Receive(w io.Writer) error

Receive loops on s.ReadChan, s.ErrChan, and s.ErrStringChan, selecting the first that occurs each iteration. If readchan receives then we are collecting input from stdout, if there is an error sent to s.ErrChan or s.ErrStringChan, we return the error. io.EOF is the expected case when no error actually occurred

func (*SilentCmd) Write

func (s *SilentCmd) Write(l string, writer io.Writer) error

Write writes l (line) to the provided writer, returning an error if any

type SilentCmds

type SilentCmds []*SilentCmd

SilentCmds is a slice of *SilentCmd

func NewSilentCmdsFromJSON

func NewSilentCmdsFromJSON(configData []byte) (SilentCmds, error)

NewSilentCmdsFromJSON loads a list of commands and inputs/outputs from a JSON file

func (SilentCmds) Exec

func (s SilentCmds) Exec() error

Exec executes all commands stored in s

Directories

Path Synopsis
package ui was taken from Packer - https://github.com/mitchellh/packer/blob/master/packer/ui.go
package ui was taken from Packer - https://github.com/mitchellh/packer/blob/master/packer/ui.go

Jump to

Keyboard shortcuts

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