Documentation
¶
Overview ¶
Package output handles terminal detection and output formatting.
Index ¶
- func FormatJSON(v interface{}) (string, error)
- func IsStderrTTY() bool
- func IsStdinTTY() bool
- func IsTTY() bool
- func PrintBatchHealthResult(result *BatchHealthResult, jsonOutput bool)
- func PrintError(err error)
- func PrintHealthResult(result *HealthResult, verbose bool)
- func PrintInfo(msg string)
- func PrintJSON(v interface{}) error
- func PrintJSONCompact(v interface{}) error
- func PrintJSONError(err error, exitCode int)
- func PrintTestResult(result *TestResult, verbose bool)
- func PrintWarning(msg string)
- func PromptConfirm(prompt string) bool
- func PromptSelect(prompt string, options []string) int
- type BatchHealthResult
- type Check
- type CheckStatus
- type HealthResult
- type PaymentOptionDisplay
- type TestResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatJSON ¶
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 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 ¶
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 PromptConfirm ¶
PromptConfirm prompts the user for yes/no confirmation. Returns true if user enters y/Y/yes.
func PromptSelect ¶
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.