ui

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: 13 Imported by: 0

README

#UI

The files ui.go, and ui_test.go are taken and derived from the excellent project Packer written by Hashicorp/Mitchel Hashimoto. (Thanks Mitchell!)

They have been renamed the ui package.

https://github.com/mitchellh/packer

Original files: https://github.com/mitchellh/packer/blob/master/packer/ui.go https://github.com/mitchellh/packer/blob/master/packer/ui_test.go

Documentation

Overview

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

Index

Constants

View Source
const (
	UiColorRed     UiColor = 31
	UiColorGreen           = 32
	UiColorYellow          = 33
	UiColorBlue            = 34
	UiColorMagenta         = 35
	UiColorCyan            = 36
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicUi

type BasicUi struct {
	Reader      io.Reader
	Writer      io.Writer
	ErrorWriter io.Writer
	// contains filtered or unexported fields
}

The BasicUI is a UI that reads and writes from a standard Go reader and writer. It is safe to be called from multiple goroutines. Machine readable output is simply logged for this UI.

func BufferUi

func BufferUi() *BasicUi

BufferUi returns a new BasicUi with its Reader, Writer, and ErrorWriter initialized to a new(bytes.Buffer)

func (*BasicUi) Ask

func (rw *BasicUi) Ask(query string) (string, error)

func (*BasicUi) Error

func (rw *BasicUi) Error(message string)

func (*BasicUi) Machine

func (rw *BasicUi) Machine(t string, args ...string)

func (*BasicUi) Message

func (rw *BasicUi) Message(message string)

func (*BasicUi) Say

func (rw *BasicUi) Say(message string)

type ColoredUi

type ColoredUi struct {
	Color      UiColor
	ErrorColor UiColor
	Ui         Ui
}

ColoredUi is a UI that is colored using terminal colors.

func NewColoredUi

func NewColoredUi() *ColoredUi

NewColoredUi returns a wrapped BasicUi(bufferui)

func (*ColoredUi) Ask

func (u *ColoredUi) Ask(query string) (string, error)

func (*ColoredUi) Err

func (u *ColoredUi) Err(message interface{})

func (*ColoredUi) Error

func (u *ColoredUi) Error(message string)

func (*ColoredUi) Machine

func (u *ColoredUi) Machine(t string, args ...string)

func (*ColoredUi) Message

func (u *ColoredUi) Message(message string)

func (*ColoredUi) Say

func (u *ColoredUi) Say(message string)

type MachineReadableUi

type MachineReadableUi struct {
	Writer io.Writer
}

MachineReadableUi is a UI that only outputs machine-readable output to the given Writer.

func (*MachineReadableUi) Ask

func (u *MachineReadableUi) Ask(query string) (string, error)

func (*MachineReadableUi) Error

func (u *MachineReadableUi) Error(message string)

func (*MachineReadableUi) Machine

func (u *MachineReadableUi) Machine(category string, args ...string)

func (*MachineReadableUi) Message

func (u *MachineReadableUi) Message(message string)

func (*MachineReadableUi) Say

func (u *MachineReadableUi) Say(message string)

type TargettedUi

type TargettedUi struct {
	Target string
	Ui     Ui
}

TargettedUi is a UI that wraps another UI implementation and modifies the output to indicate a specific target. Specifically, all Say output is prefixed with the target name. Message output is not prefixed but is offset by the length of the target so that output is lined up properly with Say output. Machine-readable output has the proper target set.

func (*TargettedUi) Ask

func (u *TargettedUi) Ask(query string) (string, error)

func (*TargettedUi) Error

func (u *TargettedUi) Error(message string)

func (*TargettedUi) Machine

func (u *TargettedUi) Machine(t string, args ...string)

func (*TargettedUi) Message

func (u *TargettedUi) Message(message string)

func (*TargettedUi) Say

func (u *TargettedUi) Say(message string)

type Ui

type Ui interface {
	Ask(string) (string, error)
	Say(string)
	Message(string)
	Error(string)
	Machine(string, ...string)
}

The Ui interface handles all communication for Packer with the outside world. This sort of control allows us to strictly control how output is formatted and various levels of output.

type UiColor

type UiColor uint

Jump to

Keyboard shortcuts

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