Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
func NewProcessor ¶
func NewProcessor(opts ...ProcessorOption) (*Processor, error)
Example ¶
stdout(`Given:`)
paths := ls(`example/`)
stdout(`
With ignore file:`)
dump(`example/.ignore`)
stdout(`Results:`)
processor, _ := NewProcessor(
WithGitignoreStrategy(),
WithIgnoreFilePath(`example/.ignore`),
)
for _, path := range paths {
if allowed, _ := processor.AllowsFile(path); allowed {
stdout(fmt.Sprintf(`✓ %s`, strings.ReplaceAll(path, "\\", "/")))
} else {
stdout(fmt.Sprintf(`✘ %s`, strings.ReplaceAll(path, "\\", "/")))
}
}
Output: Given: example/ example/.ignore example/fileA.txt example/fileB.txt example/first example/first/contents.md example/other.txt example/second example/second/contents.md example/third example/third/contents.md With ignore file: **/file*.txt !**/fileB.txt **/contents.md !**/second/contents.md Results: ✓ example/ ✓ example/.ignore ✘ example/fileA.txt ✓ example/fileB.txt ✓ example/first ✘ example/first/contents.md ✓ example/other.txt ✓ example/second ✓ example/second/contents.md ✓ example/third ✘ example/third/contents.md
type ProcessorOption ¶
func WithGitignoreStrategy ¶
func WithGitignoreStrategy() ProcessorOption
WithGitignoreStrategy is a functional option which applies the strategy for parsing .gitignore files
func WithIgnoreFilePath ¶
func WithIgnoreFilePath(filePath string) ProcessorOption
WithIgnoreFilePath is a functional option which allows the user to parse a non-standard filename for a given strategy
Click to show internal directories.
Click to hide internal directories.