Documentation
¶
Index ¶
- func Error(format string, args ...interface{})
- func FindByName(data any, field, name string) any
- func FlattenAndNormalize(data interface{}) interface{}
- func FlattenResponse(data interface{}) interface{}
- func NormalizeToArray(data interface{}) interface{}
- func Print(w io.Writer, format string, data interface{}) error
- func PrintTable(w io.Writer, columns []string, rows []map[string]string)
- func Stdout(format string, data interface{}) error
- func StdoutAuto(format string, plain bool, data interface{}) error
- func StdoutPlain(data interface{}) error
- func StdoutPlainList(format string, plain bool, data interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(format string, args ...interface{})
Error prints a formatted error message to os.Stderr.
func FindByName ¶
FindByName searches a flattened list response for an item where the given field matches name. Returns the item if found, nil otherwise. Handles both array results and single-object results from the XML-to-JSON parser.
func FlattenAndNormalize ¶
func FlattenAndNormalize(data interface{}) interface{}
FlattenAndNormalize flattens a raw API response and normalizes it to an array. Convenience wrapper for callers that need the processed value (e.g. polling loops).
func FlattenResponse ¶
func FlattenResponse(data interface{}) interface{}
FlattenResponse recursively unwraps single-key objects until it reaches an array or a meaningful multi-key object. For wrapper objects (metadata + one array), it extracts the array. This converts structures like {"TNs":{"TelephoneNumbers":{"Count":"5","TelephoneNumber":[...]}}} into just [...].
func NormalizeToArray ¶
func NormalizeToArray(data interface{}) interface{}
NormalizeToArray ensures list command output is always an array. The XML-to-JSON parser returns a single object when there's one result, which causes silent agent failures. This wraps a lone map in a slice.
func PrintTable ¶
PrintTable writes a formatted table to w with the given columns and rows.
func StdoutAuto ¶
StdoutAuto prints data to os.Stdout. If plain is true it flattens first; otherwise it uses the specified format string. Table format also flattens to unwrap API response wrappers before rendering. This is the preferred helper for command RunE functions.
func StdoutPlain ¶
func StdoutPlain(data interface{}) error
StdoutPlain prints data to os.Stdout after flattening it to a simplified structure. Intended for script and agent use where deep nesting is noise.
func StdoutPlainList ¶
StdoutPlainList is like StdoutAuto for list commands — it always normalizes the result to an array when plain is true, preventing single-item ambiguity. Table format also flattens and normalizes to unwrap API wrappers.
Types ¶
This section is empty.