Documentation
¶
Overview ¶
Package output provides the ability for Vela to manage and manipulate the output rendered for a CLI action.
Usage:
import "github.com/go-vela/cli/internal/output"
Index ¶
- Constants
- func Dump(_input any) error
- func Highlight(str string, lexer string, opts ColorOptions) string
- func JSON(_input any, colorOpts ColorOptions) error
- func RawJSON(_input any) error
- func Spew(_input any) error
- func Stderr(_input any) error
- func Stdout(_input any) error
- func YAML(_input any, colorOpts ColorOptions) error
- type ColorOptions
Constants ¶
const ( // DriverStdout defines the driver type // when outputting in stdout format. DriverStdout = "stdout" // DriverStderr defines the driver type // when outputting in stderr format. DriverStderr = "stderr" // DriverDump defines the driver type // when outputting in dump format. DriverDump = "dump" // DriverJSON defines the driver type // when outputting in JSON format. DriverJSON = "json" // DriverRawJSON defines the driver type // when outputting in raw JSON format. DriverRawJSON = "rawjson" // DriverSpew defines the driver type // when outputting in github.com/davecgh/go-spew/spew format. DriverSpew = "spew" // DriverYAML defines the driver type // when outputting in YAML format. DriverYAML = "yaml" )
output drivers.
Variables ¶
This section is empty.
Functions ¶
func Dump ¶
Dump outputs the provided input to stdout using github.com/davecgh/go-spew/spew to dump the input.
More Information:
Dump displays the passed parameters to standard out with newlines, customizable indentation, and additional debug information such as complete types and all pointer addresses used to indirect to the final value. It provides the following features over the built-in printing facilities provided by the fmt package:
- Pointers are dereferenced and followed
- Circular data structures are detected and handled properly
- Custom Stringer/error interfaces are optionally invoked, including on unexported types
- Custom types which only implement the Stringer/error interfaces via a pointer receiver are optionally invoked when passing non-pointer variables
- Byte arrays and slices are dumped like the hexdump -C command which includes offsets, byte values in hex, and ASCII output
func Highlight ¶ added in v0.24.0
func Highlight(str string, lexer string, opts ColorOptions) string
Highlight uses chroma to highlight the provided yaml string.
func JSON ¶
func JSON(_input any, colorOpts ColorOptions) error
JSON parses the provided input and renders the parsed input in pretty JSON before outputting it to stdout.
func RawJSON ¶
RawJSON parses the provided input and renders the parsed input in raw JSON before outputting it to stdout.
func Spew ¶
Spew outputs the provided input to stdout using github.com/davecgh/go-spew/spew to verbosely print the input.
func YAML ¶
func YAML(_input any, colorOpts ColorOptions) error
YAML parses the provided input and renders the parsed input in YAML before outputting it to stdout.
Types ¶
type ColorOptions ¶ added in v0.24.0
type ColorOptions struct {
Enabled bool
Format string
Theme string
ThemeLight string
UserSpecified bool
}
ColorOptions defines the output color options used for syntax highlighting.
func ColorOptionsFromCLIContext ¶ added in v0.24.0
func ColorOptionsFromCLIContext(c *cli.Command) ColorOptions
ColorOptionsFromCLIContext creates a ColorOptions from a CLI context.
func (ColorOptions) GetTheme ¶
func (opts ColorOptions) GetTheme() string
GetTheme returns the appropriate theme based on terminal background and user preferences.