formatters

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVFormatter

type CSVFormatter struct{}

CSVFormatter formats results as CSV

func NewCSVFormatter

func NewCSVFormatter() *CSVFormatter

NewCSVFormatter creates a new CSV formatter

func (*CSVFormatter) Format

func (f *CSVFormatter) Format(data interface{}, options *CSVOptions) ([]byte, error)

Format formats data as CSV

func (*CSVFormatter) FormatString

func (f *CSVFormatter) FormatString(data interface{}, options *CSVOptions) (string, error)

FormatString formats data as CSV string

type CSVOptions

type CSVOptions struct {
	Sep     string   // Separator character (default: ",")
	Quote   string   // Quote character (default: "\"")
	Path    string   // Dot-separated path to data
	Headers []string // Custom headers
	Missing string   // Value for missing cells
	Key     string   // Key name to transform dictionary to list
}

CSVOptions contains options for CSV formatting

type ExcelFormatter

type ExcelFormatter struct{}

ExcelFormatter formats results as Excel spreadsheet

func NewExcelFormatter

func NewExcelFormatter() *ExcelFormatter

NewExcelFormatter creates a new Excel formatter

func (*ExcelFormatter) Format

func (f *ExcelFormatter) Format(data interface{}, options *ExcelOptions) ([]byte, error)

Format formats data as Excel file bytes

func (*ExcelFormatter) FormatString

func (f *ExcelFormatter) FormatString(data interface{}, options *ExcelOptions) (string, error)

FormatString formats data as Excel file and returns as string (base64 encoded) Note: This is less useful for Excel, but provided for interface consistency

type ExcelOptions

type ExcelOptions struct {
	Table   []ExcelTableConfig // List of table configurations for multiple tabs
	Update  bool               // Whether to update existing file
	Path    string             // Dot-separated path to data (for single table)
	Headers []string           // Custom headers (for single table)
	Missing string             // Value for missing cells
	Key     string             // Key name to transform dictionary to list
	TabName string             // Name of the tab (for single table)
}

ExcelOptions contains options for Excel formatting

func ParseExcelOptions

func ParseExcelOptions(attrs map[string]string, content string) (*ExcelOptions, error)

ParseExcelOptions parses Excel options from a map (e.g., from output tag attributes)

type ExcelTableConfig

type ExcelTableConfig struct {
	Path    string   // Dot-separated path to data
	Headers []string // Custom headers
	Missing string   // Value for missing cells
	Key     string   // Key name to transform dictionary to list
	TabName string   // Name of the tab
	Strict  bool     // Strict mode for path traversal
}

ExcelTableConfig represents configuration for a single Excel table/tab

type Graph

type Graph struct {
	Nodes map[string]*Node
	Links []*Link
}

Graph represents a network graph with nodes and links

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter formats results as JSON

func NewJSONFormatter

func NewJSONFormatter() *JSONFormatter

NewJSONFormatter creates a new JSON formatter

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(data interface{}) ([]byte, error)

Format formats data as JSON

func (*JSONFormatter) FormatString

func (f *JSONFormatter) FormatString(data interface{}) (string, error)

FormatString formats data as JSON string

type Jinja2Formatter

type Jinja2Formatter struct{}

Jinja2Formatter formats results using Jinja2-style templates

func NewJinja2Formatter

func NewJinja2Formatter() *Jinja2Formatter

NewJinja2Formatter creates a new Jinja2 formatter

func (*Jinja2Formatter) Format

func (f *Jinja2Formatter) Format(data interface{}, template string) ([]byte, error)

Format formats data using Jinja2 template

func (*Jinja2Formatter) FormatString

func (f *Jinja2Formatter) FormatString(data interface{}, template string) (string, error)

FormatString formats data using Jinja2 template and returns as string

type Jinja2Options

type Jinja2Options struct {
	Template string // Jinja2 template string
}

Jinja2Options contains options for Jinja2 formatting

type Link struct {
	Source      string
	Target      string
	SourceLabel string
	TargetLabel string
	Properties  map[string]interface{}
}

Link represents a graph link/edge

type N2GFormatter

type N2GFormatter struct{}

N2GFormatter formats results as network diagram XML (GraphML or draw.io)

func NewN2GFormatter

func NewN2GFormatter() *N2GFormatter

NewN2GFormatter creates a new N2G formatter

func (*N2GFormatter) Format

func (f *N2GFormatter) Format(data interface{}, options *N2GOptions) ([]byte, error)

Format formats data as N2G diagram XML

func (*N2GFormatter) FormatString

func (f *N2GFormatter) FormatString(data interface{}, options *N2GOptions) (string, error)

FormatString formats data as N2G diagram XML string

type N2GOptions

type N2GOptions struct {
	Module       string                 // "yed" or "drawio"
	Path         string                 // Dot-separated path to results data
	Method       string                 // "from_list", "from_dict", "from_csv"
	MethodKwargs map[string]interface{} // Keyword arguments for method
	NodeDups     string                 // "skip", "log", "update"
	LinkDups     string                 // "skip", "log", "update"
	Algo         string                 // Layout algorithm name
}

N2GOptions contains options for N2G formatting

type Node

type Node struct {
	ID          string
	Label       string
	TopLabel    string
	BottomLabel string
	X           float64
	Y           float64
	Properties  map[string]interface{}
}

Node represents a graph node

type PPrintFormatter

type PPrintFormatter struct{}

PPrintFormatter formats results in a pretty-printed, human-readable format Similar to Python's pprint module

func NewPPrintFormatter

func NewPPrintFormatter() *PPrintFormatter

NewPPrintFormatter creates a new pprint formatter

func (*PPrintFormatter) Format

func (f *PPrintFormatter) Format(data interface{}) ([]byte, error)

Format formats data in a pretty-printed format

func (*PPrintFormatter) FormatString

func (f *PPrintFormatter) FormatString(data interface{}) (string, error)

FormatString formats data as a pretty-printed string

type RawFormatter

type RawFormatter struct{}

RawFormatter formats results as raw text

func NewRawFormatter

func NewRawFormatter() *RawFormatter

NewRawFormatter creates a new raw formatter

func (*RawFormatter) Format

func (f *RawFormatter) Format(data interface{}) ([]byte, error)

Format formats data as raw string

func (*RawFormatter) FormatString

func (f *RawFormatter) FormatString(data interface{}) (string, error)

FormatString formats data as raw string

type TableFormatter

type TableFormatter struct{}

TableFormatter formats results as a table (list of lists)

func NewTableFormatter

func NewTableFormatter() *TableFormatter

NewTableFormatter creates a new table formatter

func (*TableFormatter) Format

func (f *TableFormatter) Format(data interface{}, options *TableOptions) ([][]string, error)

Format formats data as a table (list of lists) First row is headers, subsequent rows are data

type TableOptions

type TableOptions struct {
	Path    string   // Dot-separated path to data
	Headers []string // Custom headers
	Missing string   // Value for missing cells
	Key     string   // Key name to transform dictionary to list
}

TableOptions contains options for table formatting

type TabulateFormatter

type TabulateFormatter struct{}

TabulateFormatter formats results as a text table using tabulate-style formatting Similar to Python's tabulate module

func NewTabulateFormatter

func NewTabulateFormatter() *TabulateFormatter

NewTabulateFormatter creates a new tabulate formatter

func (*TabulateFormatter) Format

func (f *TabulateFormatter) Format(data interface{}, options *TableOptions) ([]byte, error)

Format formats data as a text table

func (*TabulateFormatter) FormatString

func (f *TabulateFormatter) FormatString(data interface{}, options *TableOptions) (string, error)

FormatString formats data as a text table string

type YAMLFormatter

type YAMLFormatter struct{}

YAMLFormatter formats results as YAML

func NewYAMLFormatter

func NewYAMLFormatter() *YAMLFormatter

NewYAMLFormatter creates a new YAML formatter

func (*YAMLFormatter) Format

func (f *YAMLFormatter) Format(data interface{}) ([]byte, error)

Format formats data as YAML

func (*YAMLFormatter) FormatString

func (f *YAMLFormatter) FormatString(data interface{}) (string, error)

FormatString formats data as YAML string

Jump to

Keyboard shortcuts

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