formatter

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAgentError added in v0.14.0

func FormatAgentError(operation string, statusCode int, errMsg string, apiResponse string) (string, error)

FormatAgentError formats a structured error for agent mode.

func FormatError

func FormatError(err error) string

FormatError formats an error message

func FormatOutput

func FormatOutput(data interface{}, format OutputFormat) (string, error)

FormatOutput formats the output based on the specified format

func FormatSuccess

func FormatSuccess(message string, data interface{}) (string, error)

FormatSuccess formats a success message with optional data

func ToJSON

func ToJSON(data interface{}) (string, error)

ToJSON formats data as JSON

func ToTable

func ToTable(data interface{}) (string, error)

ToTable formats data as a table

func ToYAML

func ToYAML(data interface{}) (string, error)

ToYAML formats data as YAML

func WrapForAgent added in v0.14.0

func WrapForAgent(data interface{}, meta *Metadata) (string, error)

WrapForAgent wraps data in an AgentEnvelope and formats as JSON.

Types

type AgentEnvelope added in v0.14.0

type AgentEnvelope struct {
	Status   string      `json:"status"`
	Data     interface{} `json:"data"`
	Metadata *Metadata   `json:"metadata,omitempty"`
}

AgentEnvelope wraps API responses with metadata for agent consumption.

type AgentError added in v0.14.0

type AgentError struct {
	Status      string   `json:"status"`
	ErrorCode   int      `json:"error_code,omitempty"`
	Message     string   `json:"error_message"`
	Operation   string   `json:"operation"`
	Suggestions []string `json:"suggestions,omitempty"`
	APIResponse string   `json:"api_response,omitempty"`
}

AgentError is a structured error response for agent mode.

type Metadata added in v0.14.0

type Metadata struct {
	Count      *int     `json:"count,omitempty"`
	Truncated  bool     `json:"truncated,omitempty"`
	NextAction string   `json:"next_action,omitempty"`
	Command    string   `json:"command"`
	Warnings   []string `json:"warnings,omitempty"`
}

Metadata contains structured information about the response.

type OutputFormat

type OutputFormat string

OutputFormat represents the output format type

const (
	// FormatJSON outputs in JSON format
	FormatJSON OutputFormat = "json"
	// FormatTable outputs in table format
	FormatTable OutputFormat = "table"
	// FormatYAML outputs in YAML format
	FormatYAML OutputFormat = "yaml"
)

Jump to

Keyboard shortcuts

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