output

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequestID

func NewRequestID() string

Types

type EmitOptions

type EmitOptions struct {
	JSON           bool
	Stdout         io.Writer
	Stderr         io.Writer
	HumanFormatter func(any)
}

type Envelope

type Envelope struct {
	OK        bool
	Command   string
	RequestID string
	Data      any
	Warnings  []string
	Error     *ErrorBody
}

func Fail

func Fail(command string, code ExitCode, message string, requestID string, extra map[string]any) Envelope

func Success

func Success(command string, data any, requestID string, warnings []string) Envelope

func (Envelope) MarshalJSON

func (env Envelope) MarshalJSON() ([]byte, error)

type ErrorBody

type ErrorBody struct {
	Code    string
	Message string
	Extra   map[string]any
}

func (*ErrorBody) MarshalJSON

func (e *ErrorBody) MarshalJSON() ([]byte, error)

type ExitCode

type ExitCode int
const (
	OK ExitCode = iota
	Generic
	BadArgs
	NotAuthed
	NotFound
	FloodWait
	WriteDisallowed
	NeedsConfirm
	LocalRateLimit
	PremiumRequired
)

func Emit

func Emit(envelope Envelope, opts EmitOptions) ExitCode

func ExitCodeFromString

func ExitCodeFromString(name string) ExitCode

func (ExitCode) String

func (c ExitCode) String() string

Jump to

Keyboard shortcuts

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