filter

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MimeTypeName = "Mime-type"

Variables

View Source
var DirOnly = func(e *item.FileInfo) bool {
	return e.IsDir()
}
View Source
var HiddenOnly = func(e *item.FileInfo) bool {
	return strings.HasPrefix(e.Name(), ".")
}
View Source
var Pool *ants.Pool
View Source
var RemoveBackups = func(e *item.FileInfo) bool {
	return !strings.HasSuffix(e.Name(), "~")
}
View Source
var RemoveDir = func(e *item.FileInfo) bool {
	return !e.IsDir()
}
View Source
var RemoveHidden = func(e *item.FileInfo) bool {
	return !strings.HasPrefix(e.Name(), ".")
}

Functions

func FillBlank added in v0.8.0

func FillBlank(s string, length int) string

FillBlank if s is shorter than length, fill blank from left if s is longer than length, panic

func WhichTimeFiled added in v0.16.0

func WhichTimeFiled(mod string) (t func(os.FileInfo) time.Time)

Types

type ContentFilter

type ContentFilter struct {
	LimitN uint // <=0 means no limit
	// contains filtered or unexported fields
}

func NewContentFilter

func NewContentFilter(options ...ContentFilterOption) *ContentFilter

func (*ContentFilter) AppendToNoOutputOptions added in v0.8.0

func (cf *ContentFilter) AppendToNoOutputOptions(options ...NoOutputOption)

func (*ContentFilter) AppendToOptions added in v0.5.0

func (cf *ContentFilter) AppendToOptions(options ...ContentOption)

func (*ContentFilter) GetDisplayItems added in v0.6.0

func (cf *ContentFilter) GetDisplayItems(e *[]*item.FileInfo)

func (*ContentFilter) SetNoOutputOptions added in v0.8.0

func (cf *ContentFilter) SetNoOutputOptions(outputFunc ...NoOutputOption)

func (*ContentFilter) SetOptions added in v0.4.0

func (cf *ContentFilter) SetOptions(options ...ContentOption)

func (*ContentFilter) SetSortFunc added in v0.5.0

func (cf *ContentFilter) SetSortFunc(sortFunc func(a, b *item.FileInfo) int)

func (*ContentFilter) SortFunc added in v0.5.0

func (cf *ContentFilter) SortFunc() func(a, b *item.FileInfo) int

type ContentFilterOption added in v0.8.0

type ContentFilterOption func(cf *ContentFilter)

func WithNoOutputOptions added in v0.8.0

func WithNoOutputOptions(options ...NoOutputOption) ContentFilterOption

func WithOptions added in v0.8.0

func WithOptions(options ...ContentOption) ContentFilterOption

type ContentOption

type ContentOption func(info *item.FileInfo) (stringContent string, funcName string)

type ItemFilter added in v0.8.0

type ItemFilter struct {
	// contains filtered or unexported fields
}

func NewItemFilter added in v0.8.0

func NewItemFilter(tfs ...*ItemFilterFunc) *ItemFilter

func (*ItemFilter) AppendTo added in v0.8.0

func (tf *ItemFilter) AppendTo(typeFunc ...*ItemFilterFunc)

func (*ItemFilter) Filter added in v0.8.0

func (tf *ItemFilter) Filter(e ...*item.FileInfo) (res []*item.FileInfo)

func (*ItemFilter) Match added in v0.11.0

func (tf *ItemFilter) Match(e *item.FileInfo) bool

type ItemFilterFunc added in v0.8.0

type ItemFilterFunc = func(e *item.FileInfo) bool

ItemFilterFunc return true -> Keep return false -> remove

func AfterTime added in v0.16.0

func AfterTime(t time.Time, timeFunc func(os.FileInfo) time.Time) ItemFilterFunc

func BeforeTime added in v0.16.0

func BeforeTime(t time.Time, timeFunc func(os.FileInfo) time.Time) ItemFilterFunc

func ExtOnly

func ExtOnly(ext ...string) ItemFilterFunc

func GlobOnly added in v0.5.0

func GlobOnly(globPattern ...string) (ItemFilterFunc, error)

GlobOnly if all pattern complied successfully, return a func and nil error, if match any one, the fn will return keep, else return remove if error occurred, return nil func and error

func MimeTypeOnly added in v0.8.0

func MimeTypeOnly(fileTypes ...string) ItemFilterFunc

func RemoveByExt

func RemoveByExt(ext ...string) ItemFilterFunc

RemoveByExt

eg:
	a.go b.c c.rs d.cxx dir
	RemoveByExt([]string{"go", "cxx"})
result:
	b.c c.rs dir

func RemoveGitIgnore added in v0.4.1

func RemoveGitIgnore(repoPath git.RepoPath) ItemFilterFunc

func RemoveGlob added in v0.5.0

func RemoveGlob(globPattern ...string) (ItemFilterFunc, error)

RemoveGlob if all pattern complied successfully, return a func and nil error, if match any one, the fn will return remove, else return keep if error occurred, return nil func and error

func RemoveMimeType added in v0.8.0

func RemoveMimeType(fileTypes ...string) ItemFilterFunc

type NoOutputOption added in v0.8.0

type NoOutputOption func(info *item.FileInfo)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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