Documentation
¶
Index ¶
- Constants
- func AddOutputFlag(f *pflag.FlagSet, s *string, supportedFormats []Format, defaultFormat Format)
- func AddOutputParam(cmd *cobra.Command, supportedFormats []Format, defaultFormat Format) *cobra.Command
- func AddQueryParam(cmd *cobra.Command)
- func ApplyQuery(data interface{}, query string) (interface{}, error)
- func AzdAgentLabel() string
- func AzdLabel() string
- func EventForMessage(message string) contracts.EventEnvelope
- func TabAlign(selections []string, padding int) ([]string, error)
- func WithBackticks(s string) string
- func WithBold(text string, a ...interface{}) string
- func WithErrorFormat(text string, a ...interface{}) string
- func WithGrayFormat(text string, a ...interface{}) string
- func WithHighLightFormat(text string, a ...interface{}) string
- func WithHintFormat(text string, a ...interface{}) string
- func WithHyperlink(url string, text string) string
- func WithLinkFormat(link string, a ...interface{}) string
- func WithMarkdown(markdownText string) string
- func WithSuccessFormat(text string, a ...interface{}) string
- func WithUnderline(text string, a ...interface{}) string
- func WithWarningFormat(text string, a ...interface{}) string
- type Column
- type DynamicMultiWriter
- type EnvVarsFormatter
- type Format
- type Formatter
- type JsonFormatter
- type Link
- type NoneFormatter
- type Queryable
- type TableFormatter
- type TableFormatterOptions
Constants ¶
const ( TableColumnMinWidth = 10 TableTabSize = 4 TablePadSize = 2 TablePadCharacter = ' ' TableFlags = 0 )
Variables ¶
This section is empty.
Functions ¶
func AddOutputFlag ¶
func AddOutputParam ¶
func AddQueryParam ¶
AddQueryParam adds a hidden --query flag to the command for JMESPath filtering. This should only be called for commands that support JSON output format.
func ApplyQuery ¶
ApplyQuery applies a JMESPath query to the given data and returns the filtered result. If the query is empty, the original data is returned unchanged. If the query is invalid, an error with a hint to JMESPath documentation is returned.
func AzdAgentLabel ¶
func AzdAgentLabel() string
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 ¶
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 ¶
WithBackticks wraps text with the backtick (`) character.
func WithErrorFormat ¶
func WithGrayFormat ¶
func WithHighLightFormat ¶
withHighLightFormat creates string with highlight-looking color
func WithHintFormat ¶
func WithHyperlink ¶
WithHyperlink wraps text with the colored hyperlink format escape sequence. When stdout is not a terminal (e.g., in CI/CD pipelines like GitHub Actions), it returns the plain URL without escape codes to avoid displaying raw ANSI sequences.
func WithLinkFormat ¶
withLinkFormat creates string with hyperlink-looking color
func WithMarkdown ¶
WithMarkdown converts markdown to terminal-friendly colorized output using glamour. This provides rich markdown rendering including bold, italic, code blocks, headers, etc.
func WithSuccessFormat ¶
func WithUnderline ¶
func WithWarningFormat ¶
Types ¶
type DynamicMultiWriter ¶
type DynamicMultiWriter struct {
// contains filtered or unexported fields
}
DynamicMultiWriter allows adding/removing writers dynamically
func NewDynamicMultiWriter ¶
func NewDynamicMultiWriter(writers ...io.Writer) *DynamicMultiWriter
func (*DynamicMultiWriter) AddWriter ¶
func (d *DynamicMultiWriter) AddWriter(w io.Writer)
AddWriter adds a new writer
func (*DynamicMultiWriter) RemoveWriter ¶
func (d *DynamicMultiWriter) RemoveWriter(target io.Writer)
RemoveWriter removes a writer
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 Formatter ¶
type Formatter interface {
Kind() Format
Format(obj interface{}, writer io.Writer, opts interface{}) error
}
func NewFormatter ¶
type JsonFormatter ¶
type JsonFormatter struct {
Query string
}
func (*JsonFormatter) Format ¶
func (f *JsonFormatter) Format(obj interface{}, writer io.Writer, _ interface{}) error
func (*JsonFormatter) Kind ¶
func (f *JsonFormatter) Kind() Format
func (*JsonFormatter) QueryFilter ¶
func (f *JsonFormatter) QueryFilter(obj interface{}) (interface{}, error)
QueryFilter applies the JMESPath query (if any) to the given object. When no query is configured, the object is returned unchanged.
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 Queryable ¶
type Queryable interface {
QueryFilter(obj interface{}) (interface{}, error)
}
Queryable is an optional interface that a Formatter may implement to support JMESPath filtering on arbitrary objects. Console messages (e.g. error output) use this to apply --query without going through the full Format() pipeline.
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
}