Documentation
¶
Index ¶
- func EnsureDirectory(path string) error
- func ExpandTilde(path string) (string, error)
- func GetBasePath(path string) string
- func GetRelativePath(basePath, path string) (string, error)
- func GlobWithExcludes(patterns []string, baseDir string) ([]string, error)
- func GlobWithExcludesNoBaseDir(patterns []string) ([]string, error)
- func IsDirectory(path string) bool
- func IsSub(base, path string) (bool, error)
- func JoinPath(base string, paths ...string) string
- func NormalizePath(path string) string
- func WrapError(err error, message string) error
- type CustomError
- type ErrFileNotFound
- type ErrInvalidAgent
- type ErrInvalidConfig
- type ErrInvalidOutputFormat
- type ErrMalformedFrontmatter
- type ErrParseFailure
- type ErrTemplateExecution
- type FileSystem
- type RealFileSystem
- func (fs *RealFileSystem) FileExists(path string) bool
- func (fs *RealFileSystem) GlobWithExcludes(patterns []string, baseDir string) ([]string, error)
- func (fs *RealFileSystem) IsDir(path string) bool
- func (fs *RealFileSystem) IsFile(path string) bool
- func (fs *RealFileSystem) ListFiles(dir string, pattern string) ([]string, error)
- func (fs *RealFileSystem) ReadFile(path string) ([]byte, error)
- func (fs *RealFileSystem) ResolvePath(path string) string
- func (fs *RealFileSystem) WriteFile(path string, data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDirectory ¶
EnsureDirectory ensures a directory exists, creating it if necessary
func ExpandTilde ¶
ExpandTilde replaces a leading tilde (~) in a path with the user's home directory. If the path doesn't start with a tilde, it is returned unchanged. Returns an error if the home directory cannot be determined.
func GetBasePath ¶
GetBasePath returns the base directory of a file path
func GetRelativePath ¶
GetRelativePath returns a path relative to a base directory
func GlobWithExcludes ¶
GlobWithExcludes expands a list of glob patterns, including negative patterns (prefixed with '!'), into a deterministically sorted list of file paths.
Patterns like "**/*.md" match all markdown files recursively while "!**/*_test.md" excludes test files.
The function returns paths relative to baseDir, sorted alphabetically.
func IsDirectory ¶
IsDirectory returns true if the path is a directory
func JoinPath ¶
JoinPath joins path elements into a single path, handling both absolute and relative paths
func NormalizePath ¶
NormalizePath normalizes a path for the current platform
Types ¶
type CustomError ¶
CustomError defines the interface for custom error types that can provide formatted error messages
type ErrFileNotFound ¶
type ErrFileNotFound struct {
Path string
}
ErrFileNotFound represents a file not found error
func (*ErrFileNotFound) Error ¶
func (e *ErrFileNotFound) Error() string
func (*ErrFileNotFound) FormattedError ¶
func (e *ErrFileNotFound) FormattedError() string
FormattedError returns a user-friendly error message for file not found errors
type ErrInvalidAgent ¶
type ErrInvalidAgent struct {
Type string
}
ErrInvalidAgent represents an unknown agent type error
func (*ErrInvalidAgent) Error ¶
func (e *ErrInvalidAgent) Error() string
func (*ErrInvalidAgent) FormattedError ¶
func (e *ErrInvalidAgent) FormattedError() string
FormattedError returns a user-friendly error message for invalid agent errors
type ErrInvalidConfig ¶
type ErrInvalidConfig struct {
Reason string
}
ErrInvalidConfig represents an invalid configuration error
func (*ErrInvalidConfig) Error ¶
func (e *ErrInvalidConfig) Error() string
func (*ErrInvalidConfig) FormattedError ¶
func (e *ErrInvalidConfig) FormattedError() string
FormattedError returns a user-friendly error message for invalid configuration errors
type ErrInvalidOutputFormat ¶
type ErrInvalidOutputFormat struct {
Format string
}
ErrInvalidOutputFormat represents an invalid output format error
func (*ErrInvalidOutputFormat) Error ¶
func (e *ErrInvalidOutputFormat) Error() string
func (*ErrInvalidOutputFormat) FormattedError ¶
func (e *ErrInvalidOutputFormat) FormattedError() string
FormattedError returns a user-friendly error message for invalid output format errors
type ErrMalformedFrontmatter ¶
ErrMalformedFrontmatter represents a malformed frontmatter error
func (*ErrMalformedFrontmatter) Error ¶
func (e *ErrMalformedFrontmatter) Error() string
func (*ErrMalformedFrontmatter) FormattedError ¶
func (e *ErrMalformedFrontmatter) FormattedError() string
FormattedError returns a user-friendly error message for malformed frontmatter errors
type ErrParseFailure ¶
ErrParseFailure represents a parsing error
func (*ErrParseFailure) Error ¶
func (e *ErrParseFailure) Error() string
func (*ErrParseFailure) FormattedError ¶
func (e *ErrParseFailure) FormattedError() string
FormattedError returns a user-friendly error message for parsing errors
type ErrTemplateExecution ¶
ErrTemplateExecution represents a template execution error
func (*ErrTemplateExecution) Error ¶
func (e *ErrTemplateExecution) Error() string
func (*ErrTemplateExecution) FormattedError ¶
func (e *ErrTemplateExecution) FormattedError() string
FormattedError returns a user-friendly error message for template execution errors
type FileSystem ¶
type FileSystem interface {
// ReadFile reads a file at the given path
ReadFile(path string) ([]byte, error)
// WriteFile writes content to a file
WriteFile(path string, data []byte) error
// FileExists checks if a file exists
FileExists(path string) bool
// IsFile checks if a path exists and is a regular file
IsFile(path string) bool
// IsDir checks if a path exists and is a directory
IsDir(path string) bool
// ListFiles lists files matching a pattern
ListFiles(dir string, pattern string) ([]string, error)
// ResolvePath resolves a relative path to absolute
ResolvePath(path string) string
// GlobWithExcludes expands glob patterns with support for exclusions
GlobWithExcludes(patterns []string, baseDir string) ([]string, error)
}
FileSystem provides file system operations
type RealFileSystem ¶
type RealFileSystem struct{}
RealFileSystem implements FileSystem with the actual OS file system
func (*RealFileSystem) FileExists ¶
func (fs *RealFileSystem) FileExists(path string) bool
FileExists checks if a file exists
func (*RealFileSystem) GlobWithExcludes ¶
func (fs *RealFileSystem) GlobWithExcludes(patterns []string, baseDir string) ([]string, error)
GlobWithExcludes expands glob patterns with support for exclusions
func (*RealFileSystem) IsDir ¶
func (fs *RealFileSystem) IsDir(path string) bool
IsDir checks if a path exists and is a directory
func (*RealFileSystem) IsFile ¶
func (fs *RealFileSystem) IsFile(path string) bool
IsFile checks if a path exists and is a regular file
func (*RealFileSystem) ListFiles ¶
func (fs *RealFileSystem) ListFiles(dir string, pattern string) ([]string, error)
ListFiles lists files matching a pattern
func (*RealFileSystem) ReadFile ¶
func (fs *RealFileSystem) ReadFile(path string) ([]byte, error)
ReadFile reads a file at the given path
func (*RealFileSystem) ResolvePath ¶
func (fs *RealFileSystem) ResolvePath(path string) string
ResolvePath resolves a relative path to absolute