cmdutil

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatFor

func FormatFor(cmd *cobra.Command) output.Format

FormatFor resolves the output format for a command: --format flag takes precedence, falling back to the configured default.

func NewTransport added in v0.7.0

func NewTransport(cmd *cobra.Command, logger *slog.Logger) (transport.Transport, error)

NewTransport dials a transport using the --transport flag on the root command and the API key from config. Callers are responsible for calling Close on the returned transport.

func PrintError added in v0.7.0

func PrintError(logger *log.Logger, err error)

PrintError logs err to logger with appropriate formatting.

Special cases:

  • transport.ErrNoAPIKey → friendly "no key" message with auth hint
  • *transport.RunwareError CodeAuth → "Authentication failed" with auth hint
  • *transport.RunwareError other → re.Message, with docs URL as a "docs" field

For all other errors, err.Error() is used as the message.

func PrintErrorMsg added in v0.7.0

func PrintErrorMsg(logger *log.Logger, message string, err error)

PrintErrorMsg logs a custom message to logger, appending the documentation URL from err as a "docs" field when err is a *transport.RunwareError with one. Use this when a command needs to surface a context-specific message for an error but continue executing (warning-style) rather than exit.

Types

This section is empty.

Jump to

Keyboard shortcuts

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