output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package output provides a consistent JSON envelope for all CLI output. Every response follows the same schema so AI Agents can reliably parse output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintError

func PrintError(cErr *cliErr.CLIError) int

PrintError outputs an error response and returns the appropriate exit code.

func PrintRawError

func PrintRawError(exitCode int, code string, message string) int

PrintRawError creates a CLIError from raw parameters and prints it. Returns the exit code.

func PrintSuccess

func PrintSuccess(data interface{}, pagination *Pagination)

PrintSuccess outputs a successful response with data and optional pagination.

func SetPretty

func SetPretty(v bool)

SetPretty enables or disables indented JSON output.

Types

type ErrorDetail

type ErrorDetail struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

ErrorDetail contains structured error information.

type Pagination

type Pagination struct {
	HasNextPage bool   `json:"hasNextPage"`
	EndCursor   string `json:"endCursor,omitempty"`
}

Pagination contains cursor-based pagination info.

type Response

type Response struct {
	Success    bool         `json:"success"`
	Data       interface{}  `json:"data,omitempty"`
	Pagination *Pagination  `json:"pagination,omitempty"`
	Error      *ErrorDetail `json:"error,omitempty"`
}

Response is the standard JSON envelope for all CLI output.

Jump to

Keyboard shortcuts

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