Documentation ¶
Index ¶
- Variables
- func DisplayURL(urlStr string) string
- func DisplayWidth(s string) int
- func FormatSlice(values []string, lineLength uint, indent uint, prependWith string, ...) string
- func FuzzyAgo(a, b time.Time) string
- func FuzzyAgoAbbr(a, b time.Time) string
- func Indent(s, indent string) string
- func PadRight(maxWidth int, s string) string
- func Pluralize(num int, thing string) string
- func RemoveDiacritics(value string) string
- func RemoveExcessiveWhitespace(s string) string
- func Title(s string) string
- func Truncate(maxWidth int, s string) string
- func WithHeader(columns ...string) headerOption
- type TablePrinter
Constants ¶
This section is empty.
Variables ¶
var ( WithColor = tableprinter.WithColor WithPadding = tableprinter.WithPadding WithTruncate = tableprinter.WithTruncate )
var NoHeader = headerOption{}
NoHeader disable printing or checking for a table header.
Deprecated: use WithHeader unless required otherwise.
Functions ¶
func DisplayURL ¶
DisplayURL returns a copy of the string urlStr removing everything except the scheme, hostname, and path. If the scheme is not specified, "https" is assumed. If there is an error parsing urlStr then urlStr is returned without modification.
func DisplayWidth ¶
func FormatSlice ¶
func FormatSlice(values []string, lineLength uint, indent uint, prependWith string, appendWith string, sort bool) string
FormatSlice concatenates elements of the given string slice into a well-formatted, possibly multiline, string with specific line length limit. Elements can be optionally surrounded by custom strings (e.g., quotes or brackets). If the lineLength argument is non-positive, no line length limit will be applied.
func FuzzyAgoAbbr ¶
FuzzyAgoAbbr is an abbreviated version of FuzzyAgo. It returns a human readable string of the time duration between a and b that is estimated to the nearest unit of time.
func RemoveDiacritics ¶
RemoveDiacritics returns the input value without "diacritics", or accent marks
func RemoveExcessiveWhitespace ¶
RemoveExcessiveWhitespace returns a copy of the string s with excessive whitespace removed.
func Title ¶
Title returns a copy of the string s with all Unicode letters that begin words mapped to their Unicode title case.
func WithHeader ¶
func WithHeader(columns ...string) headerOption
WithHeader defines the column names for a table. Panics if columns is nil or empty.
Types ¶
type TablePrinter ¶
type TablePrinter struct { tableprinter.TablePrinter // contains filtered or unexported fields }
func New ¶
func New(ios *iostreams.IOStreams, headers headerOption) *TablePrinter
New creates a TablePrinter from an IOStreams.
func NewWithWriter ¶
func NewWithWriter(w io.Writer, isTTY bool, maxWidth int, cs *iostreams.ColorScheme, headers headerOption) *TablePrinter
NewWithWriter creates a TablePrinter from a Writer, whether the output is a terminal, the terminal width, and more.
func (*TablePrinter) AddTimeField ¶
func (tp *TablePrinter) AddTimeField(now, t time.Time, c func(string) string)
AddTimeField in TTY mode displays the fuzzy time difference between now and t. In non-TTY mode it just displays t with the time.RFC3339 format.
func (*TablePrinter) IsTTY ¶
func (t *TablePrinter) IsTTY() bool
IsTTY gets whether the TablePrinter will render to a terminal.