Documentation
¶
Index ¶
- Constants
- Variables
- func AsMask(sar []string) uint32
- func Exec(res *Result, opts *Options)
- func FileTraverser(opts *Options, rfn ResultFilters)
- func GenNgrams(sar []string, n int) (map[string]int, int)
- func GetScoringFunction(queries []string) func(string) float32
- func Implicit(opts *Options)
- func Initialize(opts *Options) (*Result, []Filter, []Process)
- func PrintWithBuf(els []*Finfo, opts *Options)
- func ProcessList(res *Result, fns []Process)
- func QuickCommand(arg string, opts *Options)
- func Recurse(opts *Options)
- func RegisterMasks(mask uint32, keys ...string)
- func Reverse[T any](filenames []T) []T
- func SortByScore[T any](files ScoredFiles[T])
- func StrToMask(str string) uint32
- func TraverseArgs(opts *Options, rfn ResultFilters)
- func TraverseDir(path string, depth int, opts *Options) (files []fs.FileInfo)
- func TraverseFS(opts *Options, rfn ResultFilters)
- func TraverseZip(path string, depth int, opts *Options) (files []fs.FileInfo)
- type Filter
- type FilterOpts
- type Finfo
- type FinfoParser
- type ListingOpts
- type ModeOpts
- type Options
- type Printing
- type Process
- type ProcessOpts
- type Result
- type ResultFilters
- type ScoredFiles
- type SortBy
- type Traverser
- type TreeNode
Constants ¶
View Source
const ( Other = "other" Image = "image" Video = "video" Audio = "audio" Media = "media" Archive = "archive" ZipLike = "zip" Code = "code" Conf = "conf" Docs = "docs" OtherDev = "odev" MaskImage uint32 MaskVideo MaskAudio MaskArchive MaskZipLike = 1<<iota + MaskArchive MaskCode = 1 << iota MaskConf MaskDocs MaskOtherDev )
View Source
const N = 3
Variables ¶
View Source
var CntMap = map[string]uint32{}
View Source
var CntMasks = map[uint32][]string{ MaskImage: {".jpg", ".jpeg", ".png", ".apng", ".gif", ".bmp", ".webp", ".avif", ".jxl", ".tiff"}, MaskVideo: {".mp4", ".m4v", ".webm", ".mkv", ".avi", ".mov", ".mpg", ".mpeg"}, MaskAudio: {".m4a", ".opus", ".ogg", ".mp3", ".flac", ".wav", ".aac"}, MaskArchive: {".zip", ".rar", ".7z", ".tar", ".gz", ".bz2", ".xz", ".lz4", ".zst", ".lzma", ".lzip", ".lz", ".cbz"}, MaskZipLike: {".zip", ".cbz", ".cbr"}, MaskCode: {".go", ".c", ".h", ".cpp", ".hpp", ".rs", ".py", ".js", ".ts", ".html", ".css", ".scss", ".java", ".php"}, MaskConf: {".json", ".toml", ".yaml", ".yml", ".xml", ".ini", ".cfg", ".conf", ".properties", ".env"}, MaskDocs: {".pdf", ".epub", ".mobi", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".ods", ".odp", ".txt", ".rtf", ".csv", ".tsv", ".md"}, MaskOtherDev: {".sql", ".sh", ".bat", ".cmd", ".ps1", ".psm1", ".psd1", ".ps1xml", ".pssc", ".psc1", ".pssc", ".psh"}, }
View Source
var Hide = map[string]bool{ "Thumbs.db": true, "desktop.ini": true, "Icon\r": true, "System Volume Information": true, "$RECYCLE.BIN": true, "lost+found": true, "node_modules": true, }
Hide contains commonly unwanted files and directories. Any beginning with a dot hidden by default.
Functions ¶
func FileTraverser ¶ added in v0.0.2
func FileTraverser(opts *Options, rfn ResultFilters)
func GetScoringFunction ¶
func PrintWithBuf ¶
func ProcessList ¶
func QuickCommand ¶ added in v0.0.2
func RegisterMasks ¶
func SortByScore ¶
func SortByScore[T any](files ScoredFiles[T])
func TraverseArgs ¶ added in v0.0.2
func TraverseArgs(opts *Options, rfn ResultFilters)
func TraverseDir ¶ added in v0.0.2
func TraverseFS ¶ added in v0.0.2
func TraverseFS(opts *Options, rfn ResultFilters)
TraverseFS traverses directories non-recursively and breadth first.
Types ¶
type FilterOpts ¶
type FilterOpts struct {
Search []string `` /* 170-byte string literal not displayed */
SearchAnd bool `` /* 136-byte string literal not displayed */
Include []string `short:"i" long:"include" description:"File type inclusion. Can be used multiple times."`
Exclude []string `short:"e" long:"exclude" description:"File type exclusion. Can be used multiple times."`
Ignore []string `short:"I" long:"ignore" description:"Ignores all paths which include any given strings."`
DirOnly bool `long:"dirs" description:"Only include directories in the result."`
FileOnly bool `long:"files" description:"Only include files in the result."`
}
type Finfo ¶
type Finfo struct {
Name string
Path string // includes name, relative path to cwd
Vany int64 // any numeric value, used for sorting
Mask uint32 // file kind, bitmask, see Mask* constants
IsDir bool
IsArchive bool // is a readable archive; ziplike
}
func StringParser ¶ added in v0.0.2
type FinfoParser ¶ added in v0.0.2
func InitFileParser ¶ added in v0.0.2
func InitFileParser(opts *Options) FinfoParser
type ListingOpts ¶
type ListingOpts struct {
Recurse bool `` /* 139-byte string literal not displayed */
Archive bool `short:"z" description:"Treat zip archives as directories."`
ToDepth int `short:"T" long:"todepth" description:"List files to a certain depth." default:"0"`
FromDepth int `short:"F" long:"fromdepth" description:"List files from a certain depth." default:"-1"`
DirSearch []string `` /* 210-byte string literal not displayed */
NoHide bool `short:"h" long:"hide" description:"Toggle of hiding of commonly unwanted files."`
MaxLimit int `short:"m" long:"max" description:"Maximum number of elements traversed in a single directory. Unlimited by default."`
}
type Options ¶
type Options struct {
ModeOpts `group:"Mode options - Determines which mode list executes in, fs, string, file, etc."`
ListingOpts `group:"Traversal options - Determines how the traversal is done."`
FilterOpts `group:"Filtering options - Applied while traversing, called on every entry found."`
ProcessOpts `group:"Processing options - Applied after traversal, called on the final list of files."`
Printing `group:"Printing options - Determines how the results are printed."`
ExecArgs []string
Args []string
}
type Printing ¶
type Printing struct {
Absolute bool `short:"A" long:"absolute" description:"Format paths to be absolute. Relative by default."`
Debug bool `short:"D" long:"debug" description:"Debug flag enables debug logging."`
Quiet bool `short:"Q" long:"quiet" description:"Quiet flag disables printing results."`
Count bool `short:"C" long:"count" description:"Print the number of results."`
Tree bool `long:"tree" description:"Prints as tree."`
}
type Process ¶
func CollectProcess ¶
func QueryProcess ¶
func ShuffleProcess ¶
func SliceProcess ¶
func SortProcess ¶
type ProcessOpts ¶
type ProcessOpts struct {
Query []string `short:"q" long:"query" description:"Fuzzy search query. Results will be ordered by their score."`
Ascending bool `` /* 136-byte string literal not displayed */
Sort string `` /* 206-byte string literal not displayed */
Select []string `` /* 183-byte string literal not displayed */
Shuffle bool `long:"shuffle" description:"Randomly shuffle the result."`
Seed int64 `long:"seed" description:"Seed for the random shuffle." default:"-1"`
}
type ResultFilters ¶ added in v0.0.2
type ResultFilters func(*Finfo)
func InitFilters ¶ added in v0.0.2
func InitFilters(fns []Filter, res *Result) ResultFilters
type ScoredFiles ¶
type ScoredFiles[T any] []scored[T]
func (ScoredFiles[T]) Items ¶
func (s ScoredFiles[T]) Items() []T
Items returns all T with a score above 0.
type Traverser ¶ added in v0.0.2
type Traverser func(*Options, ResultFilters)
func GetTraverser ¶ added in v0.0.2
type TreeNode ¶
type TreeNode struct {
// contains filtered or unexported fields
}
func AddFilesToTree ¶
func NewTreeNode ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.