Documentation
¶
Overview ¶
Package output formats nvfleetint command responses. It deals in plain values only: formatters that take SDK models live in internal/cmdutil.
Index ¶
- Constants
- func DisplayString(value string) string
- func FormatNameAndID(name, id string) string
- func FormatNameOrID(name, id string) string
- func FormatOptionalBool(value *bool) string
- func FormatOptionalInt(value *int) string
- func FormatOptionalPercentage(value *float32) string
- func FormatStringList(values []string) string
- func IsValidFormat(format string) bool
- func OneBasedPage(page, pageSize, total int) int
- func TotalPages(total, pageSize int) int
- func Truncate(value string, maxRunes int) string
- func WriteIndentedRows(w io.Writer, indent string, rows [][]string) error
- func WriteJSON(w io.Writer, value any) error
- func WritePaginationFooter(w io.Writer, page Pagination) error
- func WriteRawJSON(w io.Writer, data []byte) error
- func WriteTable(w io.Writer, headers []string, rows [][]string) error
- type Pagination
Constants ¶
const ( FormatTable = "table" FormatJSON = "json" )
Variables ¶
This section is empty.
Functions ¶
func DisplayString ¶
Returns a printable placeholder for empty strings
func FormatNameAndID ¶
Formats a display name with its stable identifier
func FormatNameOrID ¶
Returns the display name when present or the ID otherwise
func FormatOptionalBool ¶ added in v1.1.0
Formats optional booleans for table output. A nil value renders as "-" so a field the backend omitted is distinguishable from one reported as false.
func FormatOptionalInt ¶
Formats optional integers for table output
func FormatOptionalPercentage ¶
Formats optional percentage values for table output
func FormatStringList ¶
Formats non-empty strings as a comma-separated list
func IsValidFormat ¶
Reports whether format is a supported output format
func OneBasedPage ¶ added in v1.1.0
OneBasedPage converts an SDK page to the CLI's 1-based page number and bounds it to the available pages. Empty results are represented as page 0 of 0 so the displayed page never exceeds the total page count.
func TotalPages ¶ added in v1.1.0
TotalPages returns the number of pages needed to hold total items.
func Truncate ¶ added in v1.0.0
Truncate shortens a single-line display value to at most maxRunes runes, replacing the trailing overflow with an ellipsis. It counts runes (not bytes) so multi-byte text is not cut mid-character. Table output is a human-friendly summary; the full value remains available via -o json.
func WriteIndentedRows ¶ added in v1.1.0
Writes rows as aligned text under a common indent, with no header row. Used for sectioned output where a heading line already names the columns.
When one column holds paragraphs — a sentence-long action description beside a short code — it is wrapped on word boundaries and its continuation lines are indented to hang under the column, so the paragraph stays visually inside its cell and any columns after it stay aligned.
func WritePaginationFooter ¶
func WritePaginationFooter(w io.Writer, page Pagination) error
Writes the standard single-page pagination footer. Page carries the SDK's 0-based page number and is presented as the CLI's 1-based page.
func WriteRawJSON ¶
Writes a raw JSON payload with a trailing newline
Types ¶
type Pagination ¶
Represents pagination metadata for table footers