Documentation
¶
Index ¶
- Constants
- func ApplyTOMLFilter(input string, config *FilterConfig) (string, int)
- func MatchAndFilter(command string, output string, registry *FilterRegistry) (string, int, bool)
- func ProcessWithTOMLFilter(output string, config *FilterConfig) (string, int)
- type FilterConfig
- type FilterRegistry
- type Loader
- func (l *Loader) IsTrusted(projectPath string) bool
- func (l *Loader) ListTrusted() []string
- func (l *Loader) LoadAll(projectDir string) (*FilterRegistry, error)
- func (l *Loader) LoadTrusted() error
- func (l *Loader) TrustProject(projectPath string) error
- func (l *Loader) UntrustProject(projectPath string) error
- type LoaderConfig
- type MatchOutputRule
- type Parser
- type ReplaceRule
- type TOMLFilter
- type TOMLFilterEngine
- type TOMLFilterWrapper
Constants ¶
const SchemaVersion = 1
SchemaVersion is the expected TOML filter schema version
Variables ¶
This section is empty.
Functions ¶
func ApplyTOMLFilter ¶
func ApplyTOMLFilter(input string, config *FilterConfig) (string, int)
ApplyTOMLFilter is a convenience function to apply a TOML filter config
func MatchAndFilter ¶
MatchAndFilter finds a matching filter and applies it
func ProcessWithTOMLFilter ¶ added in v1.2.0
func ProcessWithTOMLFilter(output string, config *FilterConfig) (string, int)
ProcessWithTOMLFilter processes output using a TOML filter configuration Returns the filtered output and the number of bytes saved
Types ¶
type FilterConfig ¶ added in v1.2.0
type FilterConfig struct {
MatchCommand string `toml:"match_command"`
StripANSI bool `toml:"strip_ansi"`
Replace []ReplaceRule `toml:"replace"`
MatchOutput []MatchOutputRule `toml:"match_output"`
StripLinesMatching []string `toml:"strip_lines_matching"`
KeepLinesMatching []string `toml:"keep_lines_matching"`
TruncateLinesAt int `toml:"truncate_lines_at"`
Head int `toml:"head"`
Tail int `toml:"tail"`
MaxLines int `toml:"max_lines"`
OnEmpty string `toml:"on_empty"`
}
FilterConfig represents a single TOML filter configuration
type FilterRegistry ¶
type FilterRegistry struct {
// contains filtered or unexported fields
}
FilterRegistry holds all loaded TOML filters
func NewFilterRegistry ¶
func NewFilterRegistry() *FilterRegistry
NewFilterRegistry creates a new filter registry
func (*FilterRegistry) Count ¶
func (r *FilterRegistry) Count() int
Count returns the number of loaded filters
func (*FilterRegistry) FindMatchingFilter ¶
func (r *FilterRegistry) FindMatchingFilter(command string) (string, string, *FilterConfig)
FindMatchingFilter finds a filter that matches the given command
func (*FilterRegistry) ListFilters ¶ added in v1.2.0
func (r *FilterRegistry) ListFilters() []string
ListFilters returns all loaded filter names
func (*FilterRegistry) LoadDirectory ¶ added in v1.2.0
func (r *FilterRegistry) LoadDirectory(dir string) error
LoadDirectory loads all TOML files from a directory
func (*FilterRegistry) LoadFile ¶
func (r *FilterRegistry) LoadFile(path string) error
LoadFile loads a single TOML filter file
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles loading TOML filters from multiple sources
var GlobalFilterLoader *Loader
GlobalFilterLoader is the default loader instance
func (*Loader) ListTrusted ¶
ListTrusted returns all trusted project paths
func (*Loader) LoadAll ¶
func (l *Loader) LoadAll(projectDir string) (*FilterRegistry, error)
LoadAll loads filters from all sources with priority order: 1. Project-local: .tokman/filters.toml (requires trust) 2. User-global: ~/.config/tokman/filters.toml 3. Built-in: embedded filters
func (*Loader) LoadTrusted ¶
LoadTrusted loads the trusted projects file
func (*Loader) TrustProject ¶
TrustProject marks a project directory as trusted for filter loading
func (*Loader) UntrustProject ¶
UntrustProject removes a project from the trusted list
type LoaderConfig ¶
type LoaderConfig struct {
ConfigDir string // Base config directory (default: ~/.config/tokman)
DataDir string // Base data directory (default: ~/.local/share/tokman)
ProjectDir string // Current project directory
}
LoaderConfig configures the filter loader
type MatchOutputRule ¶
type MatchOutputRule struct {
Pattern string `toml:"pattern"`
Message string `toml:"message"`
Priority int `toml:"priority"`
Unless string `toml:"unless"` // Optional: if this pattern also matches, skip the rule
}
MatchOutputRule defines a short-circuit match rule If pattern matches, returns message immediately (short-circuit). If unless is set and also matches, the rule is skipped (prevents swallowing errors).
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser handles parsing TOML filter files
func (*Parser) ParseContent ¶
func (p *Parser) ParseContent(content []byte, source string) (*TOMLFilter, error)
ParseContent parses TOML filter content
type ReplaceRule ¶
ReplaceRule defines a regex replacement rule
type TOMLFilter ¶
type TOMLFilter struct {
SchemaVersion int `toml:"schema_version"`
Filters map[string]FilterConfig `toml:"-"`
RawContent map[string]interface{} `toml:"-"`
}
TOMLFilter represents a parsed TOML filter file
func (*TOMLFilter) MatchesCommand ¶
func (f *TOMLFilter) MatchesCommand(command string) (string, *FilterConfig, error)
MatchesCommand checks if any filter matches the given command
func (*TOMLFilter) Validate ¶
func (f *TOMLFilter) Validate() error
Validate validates the filter configuration
type TOMLFilterEngine ¶
type TOMLFilterEngine struct {
// contains filtered or unexported fields
}
TOMLFilterEngine applies TOML-defined filter rules to output
func NewTOMLFilterEngine ¶
func NewTOMLFilterEngine(config *FilterConfig) *TOMLFilterEngine
NewTOMLFilterEngine creates a new filter engine from a TOML config
type TOMLFilterWrapper ¶
type TOMLFilterWrapper struct {
// contains filtered or unexported fields
}
FilterFilter implements the filter.Filter interface for TOML filters
func NewTOMLFilterWrapper ¶
func NewTOMLFilterWrapper(name string, config *FilterConfig) *TOMLFilterWrapper
NewTOMLFilterWrapper creates a filter.Filter wrapper for a TOML filter
func (*TOMLFilterWrapper) Name ¶
func (f *TOMLFilterWrapper) Name() string
Name returns the filter name