output

package
v1.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package output formats nvfleetint command responses.

Index

Constants

View Source
const (
	FormatTable = "table"
	FormatJSON  = "json"
)

Variables

This section is empty.

Functions

func DisplayString

func DisplayString(value string) string

Returns a printable placeholder for empty strings

func FormatGeoLocation

func FormatGeoLocation(location *nvfleetint.GeoLocation) string

Formats the most useful location label available

func FormatNameAndID

func FormatNameAndID(name, id string) string

Formats a display name with its stable identifier

func FormatNameOrID

func FormatNameOrID(name, id string) string

Returns the display name when present or the ID otherwise

func FormatOptionalBool

func FormatOptionalBool(value *bool) string

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

func FormatOptionalInt(value *int) string

Formats optional integers for table output

func FormatOptionalPercentage

func FormatOptionalPercentage(value *float32) string

Formats optional percentage values for table output

func FormatStringList

func FormatStringList(values []string) string

Formats non-empty strings as a comma-separated list

func IsValidFormat

func IsValidFormat(format string) bool

Reports whether format is a supported output format

func Truncate added in v1.0.0

func Truncate(value string, maxRunes int) string

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

func WriteIndentedRows(w io.Writer, indent string, rows [][]string) error

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 WriteJSON

func WriteJSON(w io.Writer, value any) error

Writes value as a single JSON document

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

func WriteRawJSON(w io.Writer, data []byte) error

Writes a raw JSON payload with a trailing newline

func WriteTable

func WriteTable(w io.Writer, headers []string, rows [][]string) error

Writes headers and rows as tab-aligned text

Types

type Pagination

type Pagination struct {
	Page     int
	PageSize int
	Total    int
}

Represents pagination metadata for table footers

Jump to

Keyboard shortcuts

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