Documentation
¶
Overview ¶
Package core provides the core functionality for file finding and pattern matching.
Index ¶
- Constants
- type FileContent
- type FileFinder
- type FileGroup
- type FileManager
- func (fm *FileManager) DeriveOutputPaths(inputPaths []string, customOutputPath string) ([]string, error)
- func (fm *FileManager) GroupFilesByOutput(files []string, outputPaths []string) ([]FileGroup, error)
- func (fm *FileManager) ParseSize(size string) (int64, error)
- func (fm *FileManager) ValidateFiles(files []string) ([]string, error)
- type FileProcessor
- type FileResult
- type MixError
- type MixOptions
- type OutputGenerator
- type OutputType
- type PatternError
- type PatternValidator
- type Result
Constants ¶
const ( ColorRed = "\033[1;31m" // bold red ColorGreen = "\033[0;32m" // green ColorReset = "\033[0m" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileContent ¶
type FileFinder ¶ added in v0.0.2
type FileFinder struct {
// contains filtered or unexported fields
}
FileFinder handles file pattern matching and collection with support for glob patterns, symlinks, and parallel processing.
func NewFileFinder ¶ added in v0.0.2
func NewFileFinder(includes, excludes []string, followSymlinks bool) *FileFinder
NewFileFinder creates a new FileFinder with the specified include and exclude patterns. The followSymlinks parameter determines whether symbolic links should be followed.
func (*FileFinder) FindMatchingFiles ¶ added in v0.1.1
func (ff *FileFinder) FindMatchingFiles(basePaths []string) ([]string, error)
FindMatchingFiles returns all files that match the include patterns and don't match any exclude patterns. It processes directories in parallel using a worker pool for improved performance. Returns a slice of matched file paths and any error encountered during processing.
func (*FileFinder) GetRealPath ¶ added in v0.1.1
func (ff *FileFinder) GetRealPath(path string) (string, error)
GetRealPath returns the real filesystem path for a file, resolving any symbolic links.
type FileGroup ¶ added in v0.1.1
FileGroup represents a collection of files destined for the same output
type FileManager ¶ added in v0.1.1
type FileManager struct {
// contains filtered or unexported fields
}
FileManager handles file organization, path management, and size calculations
func NewFileManager ¶ added in v0.1.1
func NewFileManager(maxFileSize, maxOutputSize int64, outputType OutputType) *FileManager
NewFileManager creates a new FileManager with the specified size limits and output type
func (*FileManager) DeriveOutputPaths ¶ added in v0.1.1
func (fm *FileManager) DeriveOutputPaths(inputPaths []string, customOutputPath string) ([]string, error)
DeriveOutputPaths generates output paths for the given input paths
func (*FileManager) GroupFilesByOutput ¶ added in v0.1.1
func (fm *FileManager) GroupFilesByOutput(files []string, outputPaths []string) ([]FileGroup, error)
GroupFilesByOutput organizes files into groups based on their output destinations
func (*FileManager) ParseSize ¶ added in v0.1.1
func (fm *FileManager) ParseSize(size string) (int64, error)
ParseSize converts a size string (e.g., "10MB") to bytes
func (*FileManager) ValidateFiles ¶ added in v0.1.1
func (fm *FileManager) ValidateFiles(files []string) ([]string, error)
ValidateFiles checks files against size limits and returns valid ones
type FileProcessor ¶ added in v0.0.2
type FileProcessor struct {
// contains filtered or unexported fields
}
FileProcessor handles the concurrent processing of multiple files, including content cleaning when enabled. It manages a pool of cleaners for different languages and ensures proper resource cleanup.
func NewFileProcessor ¶ added in v0.0.2
func NewFileProcessor(options *MixOptions) *FileProcessor
NewFileProcessor creates a new FileProcessor instance with the specified options. It initializes the cleaner map if cleaning is enabled but defers actual cleaner creation until needed.
func (*FileProcessor) ProcessFiles ¶ added in v0.0.2
func (p *FileProcessor) ProcessFiles(paths []string) ([]FileContent, error)
ProcessFiles processes multiple files concurrently using a worker pool pattern. It respects file size limits and handles errors gracefully, continuing to process files even if some fail.
Parameters:
- paths: Slice of file paths to process
Returns:
- []FileContent: Slice of successfully processed file contents
- error: First error encountered during processing, if any
type FileResult ¶
type FileResult struct { Content FileContent // Processed file content and metadata Error error // Error that occurred during processing, if any }
FileResult represents the outcome of processing a single file. It can contain either the processed content or an error, but not both.
type MixOptions ¶
type MixOptions struct { InputPath string OutputPath string Pattern string Exclude string MaxFileSize int64 MaxOutputSize int64 MaxOutputFileSize int64 OutputType OutputType CleanerOptions *cleaner.CleanerOptions IgnoreSymlinks bool }
func (*MixOptions) Validate ¶ added in v0.0.4
func (m *MixOptions) Validate() error
type OutputGenerator ¶ added in v0.0.2
type OutputGenerator struct {
// contains filtered or unexported fields
}
OutputGenerator handles the creation of output files in various formats
func NewOutputGenerator ¶ added in v0.0.2
func NewOutputGenerator(options *MixOptions) (*OutputGenerator, error)
NewOutputGenerator creates a new OutputGenerator instance
func (*OutputGenerator) Generate ¶ added in v0.0.2
func (g *OutputGenerator) Generate(contents []FileContent) error
Modify the Generate method in internal/core/output.go to use the new functions:
type OutputType ¶
type OutputType string
const ( OutputTypeXML OutputType = "XML" OutputTypeJSON OutputType = "JSON" OutputTypeYAML OutputType = "YAML" )
type PatternError ¶ added in v0.1.1
func (*PatternError) Error ¶ added in v0.1.1
func (e *PatternError) Error() string
type PatternValidator ¶ added in v0.1.1
type PatternValidator struct {
// contains filtered or unexported fields
}
func NewPatternValidator ¶ added in v0.1.1
func NewPatternValidator() *PatternValidator
func (*PatternValidator) ExpandPattern ¶ added in v0.1.1
func (v *PatternValidator) ExpandPattern(pattern string) ([]string, error)
func (*PatternValidator) ValidatePattern ¶ added in v0.1.1
func (v *PatternValidator) ValidatePattern(pattern string) error