output

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package output handles formatting and writing wazuh-cli responses in JSON, Markdown, or raw formats.

Index

Constants

View Source
const (
	FormatJSON     = "json"
	FormatMarkdown = "markdown"
	FormatRaw      = "raw"
)

Format constants.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(err error) int

ExitCode translates an error to a wazuh-cli exit code.

0 = success
1 = client error (bad flags, network, config)
2 = API error
3 = auth error
4 = permission denied

func PrintInfo

func PrintInfo(quiet bool, format string, args ...interface{})

PrintInfo writes an informational message to stderr (respects --quiet via quiet flag).

func RenderTable

func RenderTable(w io.Writer, rows []map[string]interface{}) error

RenderTable writes rows as a GitHub-Flavored Markdown table. Columns are auto-detected from the union of all keys in rows.

Types

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter writes structured data to an output stream.

func New

func New(format string, pretty bool) *Formatter

New creates a Formatter for the given format.

func (*Formatter) Write

func (f *Formatter) Write(data interface{}) error

Write outputs data to stdout in the configured format. data should be json.RawMessage or any JSON-serializable value.

func (*Formatter) WriteError

func (f *Formatter) WriteError(code int, message, detail string)

WriteError outputs a machine-readable error to stdout (JSON) or stderr (other formats).

Jump to

Keyboard shortcuts

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