output

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package output handles terminal detection and output formatting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatJSON

func FormatJSON(v interface{}) (string, error)

FormatJSON returns formatted JSON as a string.

func IsStderrTTY

func IsStderrTTY() bool

IsStderrTTY returns true if stderr is connected to a terminal.

func IsStdinTTY

func IsStdinTTY() bool

IsStdinTTY returns true if stdin is connected to a terminal. When false, input is being piped.

func IsTTY

func IsTTY() bool

IsTTY returns true if stdout is connected to a terminal. When false, output is being piped or redirected.

func PrintBatchHealthResult

func PrintBatchHealthResult(result *BatchHealthResult, jsonOutput bool)

PrintBatchHealthResult outputs batch health results.

func PrintError

func PrintError(err error)

PrintError outputs an error message to stderr.

func PrintHealthResult

func PrintHealthResult(result *HealthResult, verbose bool)

PrintHealthResult outputs the health check result in human-readable format.

func PrintInfo

func PrintInfo(msg string)

PrintInfo outputs an info message to stderr (for TTY vs pipe awareness).

func PrintJSON

func PrintJSON(v interface{}) error

PrintJSON outputs any value as formatted JSON to stdout.

func PrintJSONCompact

func PrintJSONCompact(v interface{}) error

PrintJSONCompact outputs any value as compact JSON to stdout.

func PrintJSONError

func PrintJSONError(err error, exitCode int)

PrintJSONError outputs an error as JSON to stdout.

func PrintTestResult

func PrintTestResult(result *TestResult, verbose bool)

PrintTestResult outputs the test payment result in human-readable format.

func PrintWarning

func PrintWarning(msg string)

PrintWarning outputs a warning message to stderr.

func PromptConfirm

func PromptConfirm(prompt string) bool

PromptConfirm prompts the user for yes/no confirmation. Returns true if user enters y/Y/yes.

func PromptSelect

func PromptSelect(prompt string, options []string) int

PromptSelect prompts the user to select from a list of options. Returns the 0-based index of the selected option.

Types

type BatchHealthResult

type BatchHealthResult struct {
	TotalURLs  int            `json:"totalUrls"`
	Passed     int            `json:"passed"`
	PassedWarn int            `json:"passedWithWarnings"`
	Failed     int            `json:"failed"`
	Results    []HealthResult `json:"results"`
	Duration   int64          `json:"durationMs"`
}

BatchHealthResult represents the result of a batch health check.

type Check

type Check struct {
	Name    string      `json:"name"`
	Status  CheckStatus `json:"status"`
	Message string      `json:"message"`
}

Check represents a single validation check result.

type CheckStatus

type CheckStatus string

CheckStatus represents the result of a validation check.

const (
	StatusPass CheckStatus = "pass"
	StatusWarn CheckStatus = "warn"
	StatusFail CheckStatus = "fail"
)

type HealthResult

type HealthResult struct {
	URL            string                 `json:"url"`
	Method         string                 `json:"method"`
	Status         int                    `json:"status"`
	StatusText     string                 `json:"statusText"`
	Latency        int64                  `json:"latency"`
	LatencyMs      int64                  `json:"latencyMs"`
	Protocol       string                 `json:"protocol"`
	PaymentOptions []PaymentOptionDisplay `json:"paymentOptions,omitempty"`
	Checks         []Check                `json:"checks"`
	ExitCode       int                    `json:"exitCode"`
	Error          string                 `json:"error,omitempty"`
}

HealthResult contains the complete health check result.

type PaymentOptionDisplay

type PaymentOptionDisplay struct {
	Index       int    `json:"index"`
	Scheme      string `json:"scheme"`
	Network     string `json:"network"`
	NetworkName string `json:"networkName"`
	Amount      string `json:"amount"`
	AmountHuman string `json:"amountHuman"`
	Asset       string `json:"asset"`
	AssetSymbol string `json:"assetSymbol"`
	PayTo       string `json:"payTo"`
	Supported   bool   `json:"supported"`
}

PaymentOptionDisplay contains formatted payment option info for display.

type TestResult

type TestResult struct {
	URL             string               `json:"url"`
	Status          int                  `json:"status"`
	StatusText      string               `json:"statusText"`
	Protocol        string               `json:"protocol"`
	PaymentOption   PaymentOptionDisplay `json:"paymentOption"`
	Transaction     string               `json:"transaction,omitempty"`
	TransactionURL  string               `json:"transactionUrl,omitempty"`
	ResponseBody    string               `json:"responseBody,omitempty"`
	PaymentResponse interface{}          `json:"paymentResponse,omitempty"`
	DryRun          bool                 `json:"dryRun,omitempty"`
	ExitCode        int                  `json:"exitCode"`
	Error           string               `json:"error,omitempty"`
}

TestResult contains the complete test payment result.

Jump to

Keyboard shortcuts

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