dprint

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CommandDescribeTemplate = `
ID: {{.ID}}
Name: {{.Name}}

`
	GuildDescribeTemplate = `` /* 174-byte string literal not displayed */

)

Variables

View Source
var DefaultOutputManager = NewOutputManager()

DefaultOutputManager is the global default output manager

Functions

func Print

func Print(data interface{}) error

Print uses the default output manager to print data

func PrintJSON

func PrintJSON(data interface{}) error

PrintJSON uses the default output manager to print JSON

func PrintTemplate

func PrintTemplate(tpl string, v interface{}) error

func PrintYAML

func PrintYAML(data interface{}) error

PrintYAML uses the default output manager to print YAML

func SetGlobalFormat

func SetGlobalFormat(format OutputFormat)

SetGlobalFormat sets the format for the default output manager

func Table

func Table(header []string, data [][]string)

Types

type OutputFormat

type OutputFormat string

OutputFormat represents the output format type

const (
	// FormatTable outputs data as a formatted table (default)
	FormatTable OutputFormat = "table"
	// FormatJSON outputs data as JSON
	FormatJSON OutputFormat = "json"
	// FormatYAML outputs data as YAML
	FormatYAML OutputFormat = "yaml"
)

func ParseFormat

func ParseFormat(s string) (OutputFormat, error)

ParseFormat parses a string into an OutputFormat Falls back to table format for unknown formats

func (OutputFormat) String

func (f OutputFormat) String() string

String returns the string representation of the format

type OutputManager

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

OutputManager handles output formatting for different data types

func NewOutputManager

func NewOutputManager(opts ...OutputOption) *OutputManager

NewOutputManager creates a new OutputManager with the given options

func (*OutputManager) GetFormat

func (o *OutputManager) GetFormat() OutputFormat

GetFormat returns the current output format

func (*OutputManager) Print

func (o *OutputManager) Print(data interface{}) error

Print outputs data based on the configured format For table format, use PrintTable with headers and rows For JSON/YAML, pass a struct, slice, or map

func (*OutputManager) PrintJSON

func (o *OutputManager) PrintJSON(data interface{}) error

PrintJSON outputs data as formatted JSON

func (*OutputManager) PrintTable

func (o *OutputManager) PrintTable(headers []string, rows [][]string) error

PrintTable outputs data as a formatted table

func (*OutputManager) PrintTableFromStructs

func (o *OutputManager) PrintTableFromStructs(data interface{}) error

PrintTableFromStructs outputs a slice of structs as a table Uses struct tags to determine column names

func (*OutputManager) PrintYAML

func (o *OutputManager) PrintYAML(data interface{}) error

PrintYAML outputs data as formatted YAML

func (*OutputManager) SetFormat

func (o *OutputManager) SetFormat(format OutputFormat)

SetFormat changes the output format

type OutputOption

type OutputOption func(*OutputManager)

OutputOption configures the OutputManager

func WithFormat

func WithFormat(format OutputFormat) OutputOption

WithFormat sets the output format

func WithWriter

func WithWriter(w io.Writer) OutputOption

WithWriter sets the output writer (defaults to os.Stdout)

Jump to

Keyboard shortcuts

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