formatter

package
v0.0.0-...-a197711 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func MuteAnsi

func MuteAnsi()

MuteAnsi disables AnsiFormatter

func SetHostInfoList

func SetHostInfoList(list *hostlist.HostInfoList)

SetHostInfoList sets global hostlist

func SetInfo

func SetInfo(user string, concurrency int64)

SetInfo sets package var: info

Types

type AnsiFormatter

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

AnsiFormatter prints colored Outputs to stdout

func NewAnsiFormatter

func NewAnsiFormatter() *AnsiFormatter

NewAnsiFormatter sets default colors.

func (*AnsiFormatter) Add

func (af *AnsiFormatter) Add(output Output)

Add will print output to screen as AnsiFormatter is a real-time Formatter.

func (*AnsiFormatter) Print

func (af *AnsiFormatter) Print()

Print do nothing

type Formatter

type Formatter interface {
	Add(Output)
	Print()
}

Formatter formats Output for each host. Executor will send Output to Formatter with Add, and make Formatter Print when finished.

type Info

type Info struct {
	User        string
	Concurrency int64
}

Info is the shared infomation for all Formatters Formatters may want to change print style by Info

type JSONFormatter

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

JSONFormatter prints Outputs in JSON format.

func NewJSONFormatter

func NewJSONFormatter() *JSONFormatter

NewJSONFormatter is JSONFormatter's constructor

func (*JSONFormatter) Add

func (jf *JSONFormatter) Add(output Output)

Add just collects all outputs, no prints.

func (*JSONFormatter) Print

func (jf *JSONFormatter) Print()

Print prints all outputs that collected by Add

type Output

type Output struct {
	Index  int    `json:"index"`
	Stdout string `json:"stdout"`
	Stderr string `json:"stderr"`
	Error  string `json:"error"`
	// Hostname is the real host. Executor use this to connect.
	Hostname string `json:"hostname"`
	// Alias is the hostname that shown to user
	Alias    string `json:"alias"`
	ExitCode int    `json:"exitcode"`
}

Output holds executor's output. And Formatter uses it for show.

type WindowFormatter

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

WindowFormatter shows Outputs with termui

func NewWindowFormatter

func NewWindowFormatter() *WindowFormatter

NewWindowFormatter initializes a WindowFormatter, and starts it.

func (*WindowFormatter) Add

func (wf *WindowFormatter) Add(output Output)

Add binds Output to machine, and refreshes contents on screen

func (*WindowFormatter) Print

func (wf *WindowFormatter) Print()

Print waits util q/C-c.

Jump to

Keyboard shortcuts

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