output

package
v0.0.0-...-87586f8 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableColumnMinWidth = 10
	TableTabSize        = 4
	TablePadSize        = 2
	TablePadCharacter   = ' '
	TableFlags          = 0
)

Based on https://golang.org/pkg/text/tabwriter/

Variables

This section is empty.

Functions

func AddOutputFlag

func AddOutputFlag(f *pflag.FlagSet, s *string, supportedFormats []Format, defaultFormat Format)

func AddOutputParam

func AddOutputParam(cmd *cobra.Command, supportedFormats []Format, defaultFormat Format) *cobra.Command

func EventForMessage

func EventForMessage(message string) contracts.EventEnvelope

jsonObjectForMessage creates a json object representing a message. Any ANSI control sequences from the message are removed. A trailing newline is added to the message.

func TabAlign

func TabAlign(selections []string, padding int) ([]string, error)

TabAlign transforms translates tab-separated columns in input into properly aligned text with the given padding for separation. For more information, refer to the tabwriter package.

func WithBackticks

func WithBackticks(text string) string

WithBackticks wraps text with the backtick (`) character.

func WithBold

func WithBold(text string, a ...interface{}) string

func WithErrorFormat

func WithErrorFormat(text string, a ...interface{}) string

func WithGrayFormat

func WithGrayFormat(text string, a ...interface{}) string

func WithHighLightFormat

func WithHighLightFormat(text string, a ...interface{}) string

withHighLightFormat creates string with highlight-looking color

func WithHyperlink(url string, text string) string

WithHyperlink wraps text with the colored hyperlink format escape sequence.

func WithLinkFormat

func WithLinkFormat(link string, a ...interface{}) string

withLinkFormat creates string with hyperlink-looking color

func WithSuccessFormat

func WithSuccessFormat(text string, a ...interface{}) string

func WithUnderline

func WithUnderline(text string, a ...interface{}) string

func WithWarningFormat

func WithWarningFormat(text string, a ...interface{}) string

Types

type Column

type Column struct {
	Heading       string
	ValueTemplate string
	Transformer   func(string) string
}

type EnvVarsFormatter

type EnvVarsFormatter struct {
}

func (*EnvVarsFormatter) Format

func (f *EnvVarsFormatter) Format(obj interface{}, writer io.Writer, _ interface{}) error

func (*EnvVarsFormatter) Kind

func (f *EnvVarsFormatter) Kind() Format

type Format

type Format string
const (
	EnvVarsFormat Format = "dotenv"
	JsonFormat    Format = "json"
	TableFormat   Format = "table"
	NoneFormat    Format = "none"
)

type Formatter

type Formatter interface {
	Kind() Format
	Format(obj interface{}, writer io.Writer, opts interface{}) error
}

func GetCommandFormatter

func GetCommandFormatter(cmd *cobra.Command) (Formatter, error)

func NewFormatter

func NewFormatter(format string) (Formatter, error)

type JsonFormatter

type JsonFormatter struct {
}

func (*JsonFormatter) Format

func (f *JsonFormatter) Format(obj interface{}, writer io.Writer, _ interface{}) error

func (*JsonFormatter) Kind

func (f *JsonFormatter) Kind() Format
type Link struct {
	Name        string `json:"name"`
	Url         string `json:"url"`
	Description string `json:"description"`
}

type NoneFormatter

type NoneFormatter struct{}

func (*NoneFormatter) Format

func (f *NoneFormatter) Format(obj interface{}, writer io.Writer, opts interface{}) error

func (*NoneFormatter) Kind

func (f *NoneFormatter) Kind() Format

type TableFormatter

type TableFormatter struct {
}

func (*TableFormatter) Format

func (f *TableFormatter) Format(obj interface{}, writer io.Writer, opts interface{}) error

func (*TableFormatter) Kind

func (f *TableFormatter) Kind() Format

type TableFormatterOptions

type TableFormatterOptions struct {
	Columns []Column
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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