format

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package format provides code formatting utilities for resolved files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAvailableExtensions

func GetAvailableExtensions() []string

GetAvailableExtensions returns extensions for which formatters are actually available

func GetSupportedExtensions

func GetSupportedExtensions() []string

GetSupportedExtensions returns a list of file extensions that can be formatted

Types

type FormatCommand

type FormatCommand struct {
	Success             bool           `json:"success"`
	FilesProcessed      int            `json:"files_processed"`
	FilesFormatted      int            `json:"files_formatted"`
	FilesFailed         int            `json:"files_failed"`
	Results             []FormatResult `json:"results"`
	AvailableFormatters []Formatter    `json:"available_formatters"`
	Timestamp           string         `json:"timestamp"`
	Duration            string         `json:"duration"`
}

FormatCommand represents the complete format command result

func FormatFiles

func FormatFiles(filePaths []string) *FormatCommand

FormatFiles formats multiple files and returns a comprehensive result

func FormatFilesWithOptions

func FormatFilesWithOptions(filePaths []string, options FormatOptions) *FormatCommand

FormatFilesWithOptions formats files with custom options

type FormatOptions

type FormatOptions struct {
	DryRun              bool          `json:"dry_run"`
	PreferredFormatters []string      `json:"preferred_formatters,omitempty"`
	ExcludeFormatters   []string      `json:"exclude_formatters,omitempty"`
	Timeout             time.Duration `json:"timeout,omitempty"`
	Concurrency         int           `json:"concurrency,omitempty"`
}

FormatOptions contains options for formatting files

type FormatResult

type FormatResult struct {
	File      string `json:"file"`
	Formatter string `json:"formatter"`
	Success   bool   `json:"success"`
	Error     string `json:"error,omitempty"`
	Stdout    string `json:"stdout,omitempty"`
	Stderr    string `json:"stderr,omitempty"`
	Duration  string `json:"duration"`
}

FormatResult represents the result of formatting a single file

func FormatFile

func FormatFile(filePath string) *FormatResult

FormatFile applies appropriate formatting to a file based on its extension

type Formatter

type Formatter struct {
	Name        string   `json:"name"`
	Command     string   `json:"command"`
	Args        []string `json:"args"`
	Extensions  []string `json:"extensions"`
	Description string   `json:"description"`
	Available   bool     `json:"available"`
	Version     string   `json:"version,omitempty"`
}

Formatter represents a code formatter with its configuration

func GetFormattersForFile

func GetFormattersForFile(filePath string) []Formatter

GetFormattersForFile returns available formatters for a specific file

func GetSupportedFormatters

func GetSupportedFormatters() []Formatter

GetSupportedFormatters returns all known formatters with their configurations

type FormatterDiscovery

type FormatterDiscovery struct {
	Formatters []Formatter `json:"formatters"`
	Timestamp  string      `json:"timestamp"`
}

FormatterDiscovery represents the discovery of available formatters

func DiscoverFormatters

func DiscoverFormatters() *FormatterDiscovery

DiscoverFormatters scans the system for available formatters

Jump to

Keyboard shortcuts

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