format

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTableList

func FormatTableList(list []string) string

FormatTableList formats a list of Mark objects into a string Receive a | separated list of strings and make sure that the columns are aligned with the same width

Example:

Input
1 | app1 | title1
2 | app2 super long | title2
3 | app3 | title3

Output
1 | app1             | title1
2 | app2 super long  | title2
3 | app3             | title3

Types

type ListOutputFormatter added in v1.0.0

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

ListOutputFormatter formats a list of marked windows.

func NewListOutputFormatter added in v1.0.0

func NewListOutputFormatter(w io.Writer, format string) (*ListOutputFormatter, error)

NewListOutputFormatter creates a new ListOutputFormatter.

func (*ListOutputFormatter) Format added in v1.0.0

func (f *ListOutputFormatter) Format(windows []MarkedWindow) error

Format formats and writes the list of marked windows.

func (*ListOutputFormatter) FormatEmpty added in v1.0.0

func (f *ListOutputFormatter) FormatEmpty(message string) error

FormatEmpty formats and writes empty results with an optional message for text format. For JSON, outputs "[]". For CSV, outputs header only. For text, outputs the message.

type MarkedWindow added in v1.0.0

type MarkedWindow struct {
	Mark        string `json:"mark"`
	WindowID    int    `json:"window_id"`
	AppName     string `json:"app_name"`
	WindowTitle string `json:"window_title"`
	Workspace   string `json:"workspace"`
	AppBundleID string `json:"app_bundle_id"`
}

MarkedWindow represents a window with its mark.

type OutputEvent added in v1.0.0

type OutputEvent struct {
	Command         string `json:"command"`
	Action          string `json:"action"`
	WindowID        int    `json:"window_id"`
	AppName         string `json:"app_name"`
	Workspace       string `json:"workspace"`
	TargetWorkspace string `json:"target_workspace"`
	Result          string `json:"result"`
	Message         string `json:"message"`
}

OutputEvent describes a single command result in a structured way.

type OutputEventFormatter added in v1.0.0

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

OutputEventFormatter formats a single command result event.

func NewOutputEventFormatter added in v1.0.0

func NewOutputEventFormatter(w io.Writer, format string) (*OutputEventFormatter, error)

NewOutputEventFormatter creates a new OutputEventFormatter.

func (*OutputEventFormatter) Format added in v1.0.0

func (f *OutputEventFormatter) Format(event OutputEvent) error

Format formats and writes a single output event.

type OutputFormat added in v1.0.0

type OutputFormat string

OutputFormat represents the output format type.

const (
	// OutputFormatText is the default pipe-separated text format.
	OutputFormatText OutputFormat = "text"
	// OutputFormatJSON outputs data as JSON array.
	OutputFormatJSON OutputFormat = "json"
	// OutputFormatCSV outputs data as comma-separated values.
	OutputFormatCSV OutputFormat = "csv"
)

Jump to

Keyboard shortcuts

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