Documentation ¶
Overview ¶
Package replyfmt formats Replies for presentation to users
Index ¶
- Constants
- func FormatAggregates(w io.Writer, f OutputFormat, action ActionDDL, opts ...Option) error
- func FormatReply(w io.Writer, f OutputFormat, action ActionDDL, sender string, ...) error
- type ActionDDL
- type ConsoleFormatter
- func (c *ConsoleFormatter) FormatAggregates(w io.Writer, action ActionDDL) error
- func (c *ConsoleFormatter) FormatReply(w io.Writer, action ActionDDL, sender string, reply *client.RPCReply) error
- func (c *ConsoleFormatter) SetDisplay(m DisplayMode)
- func (c *ConsoleFormatter) SetSilent()
- func (c *ConsoleFormatter) SetVerbose()
- type DisplayMode
- type Formatter
- type Logger
- type Option
- type OutputFormat
- type RPCReply
- type RPCResults
- func (r *RPCResults) RenderJSON(w io.Writer, action ActionDDL) (err error)
- func (r *RPCResults) RenderTXT(w io.Writer, action ActionDDL, verbose bool, silent bool, display DisplayMode, ...) (err error)
- func (r *RPCResults) RenderTXTFooter(w io.Writer, verbose bool)
- func (r *RPCResults) RenderTable(w io.Writer, action ActionDDL) (err error)
- type RPCStats
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 ¶
Types ¶
type ActionDDL ¶ added in v0.16.0
type ActionDDL interface { SetOutputDefaults(results map[string]interface{}) AggregateResult(result map[string]interface{}) error AggregateResultJSON(jres []byte) error AggregateSummaryJSON() ([]byte, error) GetOutput(string) (*common.OutputItem, bool) AggregateSummaryFormattedStrings() (map[string][]string, error) DisplayMode() string OutputNames() []string }
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 io.Writer, action ActionDDL) error
func (*ConsoleFormatter) FormatReply ¶
func (*ConsoleFormatter) SetDisplay ¶
func (c *ConsoleFormatter) SetDisplay(m DisplayMode)
func (*ConsoleFormatter) SetSilent ¶
func (c *ConsoleFormatter) SetSilent()
func (*ConsoleFormatter) SetVerbose ¶
func (c *ConsoleFormatter) SetVerbose()
type Formatter ¶
type Formatter interface { FormatReply(w io.Writer, action ActionDDL, sender string, reply *client.RPCReply) error FormatAggregates(w io.Writer, action ActionDDL) error SetVerbose() SetSilent() SetDisplay(mode DisplayMode) }
Formatter formats and writes a reply into the bufio writer
type Option ¶
Option configures a formatter
func ConsoleNoColor ¶
func ConsoleNoColor() Option
ConsoleNoColor disables color in the console formatter
func Display ¶
func Display(d DisplayMode) Option
type RPCResults ¶ added in v0.16.0
type RPCResults struct { Agent string `json:"agent"` Action string `json:"action"` Replies []*RPCReply `json:"replies"` Stats *rpc.Stats `json:"-"` ParsedStats *RPCStats `json:"request_stats"` Summaries json.RawMessage `json:"summaries"` }
func (*RPCResults) RenderJSON ¶ added in v0.16.0
func (r *RPCResults) RenderJSON(w io.Writer, action ActionDDL) (err error)
func (*RPCResults) RenderTXT ¶ added in v0.16.0
func (r *RPCResults) RenderTXT(w io.Writer, action ActionDDL, verbose bool, silent bool, display DisplayMode, colorize bool, log Logger) (err error)
func (*RPCResults) RenderTXTFooter ¶ added in v0.17.0
func (r *RPCResults) RenderTXTFooter(w io.Writer, verbose bool)
func (*RPCResults) RenderTable ¶ added in v0.17.0
func (r *RPCResults) RenderTable(w io.Writer, action ActionDDL) (err error)
RenderTable renders a table of outputs TODO: should become a reply format formatter, but those lack a prepare phase to print headers etc
type RPCStats ¶ added in v0.16.0
type RPCStats struct { RequestID string `json:"requestid"` NoResponses []string `json:"no_responses"` UnexpectedResponses []string `json:"unexpected_responses"` DiscoveredCount int `json:"discovered"` FailCount int `json:"failed"` OKCount int `json:"ok"` ResponseCount int `json:"responses"` PublishTime time.Duration `json:"publish_time"` RequestTime time.Duration `json:"request_time"` DiscoverTime time.Duration `json:"discover_time"` StartTime time.Time `json:"start_time_utc"` }
Click to show internal directories.
Click to hide internal directories.