Documentation ¶
Overview ¶
Package cli contains utilities to work with IO streams and to improve CLI output, such as a custom log handler and a table writer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
DefaultIOStreams provides the default streams for os.Stdin, os.Stdout and os.Stderr.
Functions ¶
This section is empty.
Types ¶
type IOStreams ¶
IOStreams is a holder for input and output streams. Commands should use this instead of directly relying on os.Stdin, os.Stdout and os.Stderr to make it possible to replace the streams in tests.
func NewTestIOStreams ¶
NewTestIOStreams provides IOStreams that use a *bytes.Buffer. This can be used in tests to make assertions on command output as well as control the input stream. Returns IOStreams and *bytes.Buffer for in, out and errOut.
type TableWriter ¶
type TableWriter interface { // Append appends a row to the table. Append(row ...string) // SetHeader sets the table's header keys. SetHeader(keys ...string) // SetTablePadding sets the table's padding character(s). SetTablePadding(padding string) // Render renders the table. Render() }
A TableWriter can create formatted tables.
func NewTableWriter ¶
func NewTableWriter(w io.Writer) TableWriter
NewTableWriter creates a new TableWriter which writes the table to w upon calling Render().