output

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package output centralizes result formatting (console, txt, json) for SwaggerVu.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Status

func Status(code int) string

Status renders an HTTP status code colored by class (when output is a TTY): 2xx green, 3xx cyan, 4xx yellow, 5xx red. Other codes are left uncolored.

Types

type Logger

type Logger struct {
	Quiet bool
	// contains filtered or unexported fields
}

Logger writes human-readable status to stderr, keeping stdout pipe-clean.

func (*Logger) Banner

func (l *Logger) Banner(version string)

Banner prints the SwaggerVu banner to stderr unless quiet.

func (*Logger) Error

func (l *Logger) Error(format string, a ...any)

func (*Logger) Good

func (l *Logger) Good(format string, a ...any)

func (*Logger) Info

func (l *Logger) Info(format string, a ...any)

func (*Logger) Progress added in v1.0.2

func (l *Logger) Progress(format string, a ...any)

Progress draws a transient single-line status to stderr, overwriting the previous one (carriage return, no newline). It is a no-op when quiet or when stderr is not a TTY, keeping redirected/piped logs clean. Call ProgressDone to terminate the line. Safe for concurrent use.

func (*Logger) ProgressDone added in v1.0.2

func (l *Logger) ProgressDone()

ProgressDone terminates an active progress line with a newline so subsequent output starts cleanly. No-op if no progress line is active.

func (*Logger) Warn

func (l *Logger) Warn(format string, a ...any)

type Sink

type Sink struct {
	// contains filtered or unexported fields
}

Sink collects result lines and flushes them to stdout or a file.

func NewSink

func NewSink(path string, asJSON bool) (*Sink, error)

NewSink opens an output sink. If path is empty, writes to stdout.

func (*Sink) Add

func (s *Sink) Add(item any)

Add stores a structured item for JSON output.

func (*Sink) Close

func (s *Sink) Close() error

Close flushes JSON (if enabled) and closes the underlying file.

func (*Sink) IsJSON

func (s *Sink) IsJSON() bool

IsJSON reports whether the sink is in JSON mode.

func (*Sink) WriteLine

func (s *Sink) WriteLine(line string)

WriteLine writes a plain text line (used in non-JSON mode).

Jump to

Keyboard shortcuts

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