replyfmt

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package replyfmt formats Replies for presentation to users

Index

Constants

View Source
const (
	DisplayDDL = DisplayMode(iota)
	DisplayOK
	DisplayFailed
	DisplayAll
	DisplayNone
)
View Source
const (
	// UnknownFormat is an unknown format
	UnknownFormat = OutputFormat(iota)

	// ConsoleFormat is a format suitable for displaying on the console
	ConsoleFormat
)

Variables

This section is empty.

Functions

func FormatAggregates

func FormatAggregates(w *bufio.Writer, f OutputFormat, action *agent.Action, opts ...Option) error

func FormatReply

func FormatReply(w *bufio.Writer, f OutputFormat, action *agent.Action, sender string, reply *client.RPCReply, opts ...Option) error

Types

type ConsoleFormatter

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

func NewConsoleFormatter

func NewConsoleFormatter(opts ...Option) *ConsoleFormatter

func (*ConsoleFormatter) FormatAggregates

func (c *ConsoleFormatter) FormatAggregates(w *bufio.Writer, action *agent.Action) error

func (*ConsoleFormatter) FormatReply

func (c *ConsoleFormatter) FormatReply(w *bufio.Writer, action *agent.Action, sender string, reply *client.RPCReply) error

func (*ConsoleFormatter) SetDisplay

func (c *ConsoleFormatter) SetDisplay(m DisplayMode)

func (*ConsoleFormatter) SetSilent

func (c *ConsoleFormatter) SetSilent()

func (*ConsoleFormatter) SetVerbose

func (c *ConsoleFormatter) SetVerbose()

type DisplayMode

type DisplayMode uint8

DisplayMode overrides the DDL display hints

type Formatter

type Formatter interface {
	FormatReply(w *bufio.Writer, action *agent.Action, sender string, reply *client.RPCReply) error
	FormatAggregates(w *bufio.Writer, action *agent.Action) error

	SetVerbose()
	SetSilent()
	SetDisplay(mode DisplayMode)
}

Formatter formats and writes a reply into the bufio writer

type Option

type Option func(f Formatter) error

Option configures a formatter

func ConsoleNoColor

func ConsoleNoColor() Option

ConsoleNoColor disables color in the console formatter

func Display

func Display(d DisplayMode) Option

func Silent

func Silent() Option

silent sets verbose output mode

func Verbose

func Verbose() Option

verbose sets verbose output mode

type OutputFormat

type OutputFormat uint8

OutputFormat is the format of reply desired

Jump to

Keyboard shortcuts

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