Documentation
¶
Index ¶
- Variables
- func Bold(msg string) string
- func ColorEnabled() bool
- func Confirm(prompt string) bool
- func Dim(msg string) string
- func Error(msg string) string
- func Format(cmd *cobra.Command) string
- func HumanTime(t time.Time) string
- func Info(msg string) string
- func InitColor(noColorFlag bool)
- func Print(cmd *cobra.Command, data interface{}, tableFn TableFunc) error
- func PrintJSON(w io.Writer, data interface{}, compact bool) error
- func PrintTable(w io.Writer, headers []string, rows [][]string, opts *TableOptions) error
- func PrintYAML(w io.Writer, data interface{}) error
- func Spin(ctx context.Context, message string, action func() error) error
- func Success(msg string) string
- func Summary(w io.Writer, shown, total int)
- func Table(w io.Writer, headers []string, fn func(tw *tabwriter.Writer)) error
- func Warn(msg string) string
- type ProgressWriter
- type TableFunc
- type TableOptions
- type TableRenderable
Constants ¶
This section is empty.
Variables ¶
var IsInteractiveStdin = func() bool { return isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd()) }
IsInteractiveStdin reports whether stdin is connected to a TTY. Destructive commands check this before showing an interactive prompt so they can fail with a clear error in CI rather than silently aborting on EOF.
We resolve this through a package-level variable so tests can swap in a fixed value without touching real file descriptors.
Functions ¶
func ColorEnabled ¶
func ColorEnabled() bool
ColorEnabled returns true if colored output is allowed.
func HumanTime ¶
HumanTime formats a timestamp as a human-friendly relative time. Times older than 30 days are shown as absolute dates.
func InitColor ¶
func InitColor(noColorFlag bool)
InitColor sets up color state from the --no-color flag. Call once from root PersistentPreRun.
func Print ¶
Print outputs data in the format specified by the --output flag. For json/yaml it marshals data directly. For table it calls tableFn. If tableFn is nil and data implements TableRenderable, the table is built automatically.
func PrintTable ¶
PrintTable renders rows as a tab-aligned table with optional colored headers.
func Spin ¶
Spin shows a spinner with the given message while action runs. If stdout is not a TTY, it prints the message and runs the action without a spinner.
Types ¶
type ProgressWriter ¶
type ProgressWriter struct {
Writer io.Writer
Total int64
// contains filtered or unexported fields
}
ProgressWriter wraps an io.Writer and prints a progress bar to stderr.
func NewProgressWriter ¶
func NewProgressWriter(w io.Writer, total int64, label string) *ProgressWriter
NewProgressWriter returns a writer that displays upload/download progress.
type TableOptions ¶
type TableOptions struct {
NoHeader bool // Skip the header row
Wide bool // Show all columns (unused by default; commands define wide sets)
MaxWidth int // Max column width before truncation (0 = 40)
}
TableOptions controls table rendering behavior.
type TableRenderable ¶
TableRenderable can be implemented by SDK response types for automatic table rendering.