Documentation
¶
Index ¶
- Constants
- func Error(cmd *cobra.Command, err error, verbose bool)
- func GreenPrint(message string)
- func Info(message string)
- func OrganizationInfo(orgID string, verbose bool)
- func Print(message string)
- func PrintDetail(label, value string)
- func PrintHeader(message string)
- func PrintNorm(message string)
- func Prompt(message string, verbose bool)
- func Success(message string)
- func Warning(message string)
- func YellowPrint(message string)
- type CPrinter
- func (p *CPrinter) Emit(result map[string]any) error
- func (p *CPrinter) Error(cmd *cobra.Command, err error)
- func (p *CPrinter) GreenPrint(message string)
- func (p *CPrinter) Info(message string)
- func (p *CPrinter) IsJSON() bool
- func (p *CPrinter) Messages() []Message
- func (p *CPrinter) OrganizationInfo(orgID string)
- func (p *CPrinter) Print(message string)
- func (p *CPrinter) PrintDetail(label, value string)
- func (p *CPrinter) PrintHeader(message string)
- func (p *CPrinter) PrintNorm(message string)
- func (p *CPrinter) PrintVerbose(message string)
- func (p *CPrinter) Prompt(message string)
- func (p *CPrinter) SetFormat(format string)
- func (p *CPrinter) Success(message string)
- func (p *CPrinter) Warning(message string)
- func (p *CPrinter) YellowPrint(message string)
- type Message
Constants ¶
const ( LevelInfo = "info" LevelSuccess = "success" LevelWarning = "warning" LevelError = "error" LevelVerbose = "verbose" )
Message levels recorded in the JSON payload.
const FormatJSON = "json"
FormatJSON selects structured JSON output. Callers set it via SetFormat on a CPrinter. Consumers wrapping the CLI (e.g. the deploy-action GitHub wrapper) rely on this contract to parse results.
Variables ¶
This section is empty.
Functions ¶
func GreenPrint ¶
func GreenPrint(message string)
func OrganizationInfo ¶
func PrintDetail ¶
func PrintDetail(label, value string)
func PrintHeader ¶
func PrintHeader(message string)
func YellowPrint ¶
func YellowPrint(message string)
Types ¶
type CPrinter ¶ added in v0.12.6
type CPrinter struct {
// contains filtered or unexported fields
}
CPrinter holds the configuration for printing. Safe for concurrent use — callbacks from socket.io event streams call the printer from goroutines other than the main one, so the messages buffer needs a mutex.
func NewCPrinter ¶ added in v0.12.6
NewCPrinter creates a new CPrinter instance
func (*CPrinter) Emit ¶ added in v0.27.0
Emit renders the final output of a command.
- In human mode it is a no-op — individual messages have already been streamed to stdout as they happened.
- In json mode it merges the caller's result fields with a "messages" array of everything recorded during the run and writes a single JSON object to stdout on its own line.
The caller owns the result keys. A "messages" key in result is overwritten by the printer's recorded messages — the CLI owns that slot.
func (*CPrinter) Error ¶ added in v0.12.6
CPrinter methods — in human mode each streams the message to stdout; in JSON mode each records the message into the buffer for Emit to include in the final payload. Messages are not recorded in human mode so long-running commands don't accumulate them in memory.
func (*CPrinter) GreenPrint ¶ added in v0.12.6
func (*CPrinter) IsJSON ¶ added in v0.27.0
IsJSON reports whether the printer is in structured JSON mode.
func (*CPrinter) Messages ¶ added in v0.27.0
Messages returns a copy of the messages recorded so far. Exposed mostly for tests; returning a copy keeps callers from mutating printer state.
func (*CPrinter) OrganizationInfo ¶ added in v0.12.6
func (*CPrinter) PrintDetail ¶ added in v0.12.6
func (*CPrinter) PrintHeader ¶ added in v0.12.6
func (*CPrinter) PrintVerbose ¶ added in v0.16.0
PrintVerbose records and prints only when verbose mode is enabled.
func (*CPrinter) SetFormat ¶ added in v0.27.0
SetFormat selects how this printer renders output. The zero value (empty string) is the default human-readable mode. FormatJSON suppresses streaming progress and buffers messages into the JSON payload emitted by Emit.
func (*CPrinter) YellowPrint ¶ added in v0.12.6
type Message ¶ added in v0.27.0
Message is a user-facing line buffered by the printer in JSON output mode and emitted as part of the final JSON object produced by Emit. In human mode messages are streamed to stdout as they happen and are not buffered, so long-running commands (e.g. hx deploy monitoring a pipeline) don't accumulate them in memory.