{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package formatter\n\n## Constants\n\n```go\nconst (\n\tTableFormatKey  = \"table\"\n\tRawFormatKey    = \"raw\"\n\tPrettyFormatKey = \"pretty\"\n)\n```\nFormat keys used to specify certain kinds of output formats\n\n## Functions\n\n```go\nfunc ContainerStatsWrite(ctx Context, containerStats []StatsEntry) error\n```\nContainerStatsWrite renders the context for a list of containers statistics\n\n## Types\n\n```go\ntype ContainerStats struct {\n\tStatsEntry\n\t// contains filtered or unexported fields\n}\n```\nContainerStats represents an entity to store containers statistics synchronously\n\n```go\nfunc NewContainerStats(container string) *ContainerStats\n```\nNewContainerStats returns a new ContainerStats entity and sets in it the given name\n\n```go\nfunc (cs *ContainerStats) GetError() error\n```\nGetError returns the container statistics error. This is used to determine whether the statistics are valid or not\n\n```go\nfunc (cs *ContainerStats) GetStatistics() StatsEntry\n```\nGetStatistics returns container statistics with other meta data such as the container name\n\n```go\nfunc (cs *ContainerStats) SetError(err error)\n```\nSetError sets container statistics error\n\n```go\nfunc (cs *ContainerStats) SetErrorAndReset(err error)\n```\nSetErrorAndReset zeroes all the container statistics and store the error. It is used when receiving time out error during statistics collecting to reduce lock overhead\n\n```go\nfunc (cs *ContainerStats) SetStatistics(s StatsEntry)\n```\nSetStatistics set the container statistics\n\n```go\ntype Context struct {\n\t// Output is the output stream to which the formatted string is written.\n\tOutput io.Writer\n\t// Format is used to choose raw, table or custom format for the output.\n\tFormat Format\n\t// Trunc when set to true will truncate the output of certain fields such as Container ID.\n\tTrunc bool\n\t// contains filtered or unexported fields\n}\n```\nContext contains information required by the formatter to print the output as desired.\n\n```go\nfunc (c *Context) Write(sub subContext, f SubFormat) error\n```\nWrite the template to the buffer using this Context\n\n```go\ntype Format string\n```\nFormat is the format string rendered using the Context\n\n```go\nfunc NewStatsFormat(source string) Format\n```\nNewStatsFormat returns a format for rendering an CStatsContext\n\n```go\nfunc (f Format) Contains(sub string) bool\n```\nContains returns true if the format contains the substring\n\n```go\nfunc (f Format) IsTable() bool\n```\nIsTable returns true if the format is a table-type format\n\n```go\ntype HeaderContext struct {\n\t// contains filtered or unexported fields\n}\n```\nHeaderContext provides the subContext interface for managing headers\n\n```go\nfunc (c *HeaderContext) AddHeader(header string)\n```\nAddHeader adds another column to the header\n\n```go\nfunc (c *HeaderContext) FullHeader() string\n```\nFullHeader returns the header as a string\n\n```go\ntype StatsEntry struct {\n\tContainer        string\n\tName             string\n\tID               string\n\tCPUPercentage    float64\n\tMemory           float64\n\tMemoryLimit      float64\n\tMemoryPercentage float64\n\tNetworkRx        float64\n\tNetworkTx        float64\n\tBlockRead        float64\n\tBlockWrite       float64\n\tIsInvalid        bool\n}\n```\nStatsEntry represents represents the statistics data collected from a container\n\n```go\ntype SubFormat func(func(subContext) error) error\n```\nSubFormat is a function type accepted by Write()\n\n","path":"github.com/hyperhq/hypercli/cli/command/formatter","name":"formatter","synopsis":"","isRedistributable":true}
