fzd

package module
v0.0.0-...-ac0478e Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 13 Imported by: 0

README ¶

📂 fzd

Golang file indexer and fuzzy file finder utiliy tool

🔨 Build

go install ./cmd/fzd

🛠 Usage

Copy .fzd.example.yaml and place it in as $HOME/.fzd/.fzd.yaml in your home directory.

Tweak the configurations for your case, may take a look at detailed configuration list.

$ fzd
Index is not created yet
Do you want to create it now [y/N]: y
Indexed for 102 files

$ fzd test
/home/test.json
/home/Projects/zzz-test
/home/Projects/zzz_test
/home/Projects/file_tests
/home/Projects/more_file_tests

$ fzd -n 3 test
/home/test.json
/home/Projects/zzz-test
/home/Projects/zzz_test

$ fzd -num 3 test
/home/test.json
/home/Projects/zzz-test
/home/Projects/zzz_test

âš™ Configuration

Coming soon

🚢 Release

go install github.com/mitchellh/gox@latest

gox -output ./build/{{.Dir}}_{{.OS}}_{{.Arch}} ./cmd/fzd

📜 License

Distributed under the MIT License. See LICENSE for more information.

Documentation ¶

Overview ¶

Package for library

Index ¶

Constants ¶

View Source
const (
	HeadFileName = "HEAD"
)

Variables ¶

View Source
var (
	// Error where index is not opened
	ErrIndexNotOpened = errors.New("index is not opened")

	// Error where HEAD file does not exists, it should only occur when opened without previously indexed
	ErrIndexHeadDoesNotExist = fmt.Errorf("cannot open index, %v file does not exist", HeadFileName)
)

Functions ¶

This section is empty.

Types ¶

type Filter ¶

type Filter string

Filter for filtering file entries while traversing through file trees

const (
	// Top filters only immediate descendant of the path
	Top Filter = "top"

	// Dir filters only directories
	Dir Filter = "dir"

	// NotDir filters only non directories
	NotDir Filter = "not_dir"
)

type Indexer ¶

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

Indexer manages file path indexes, which provides atomic reindex swapping

func NewIndexer ¶

func NewIndexer(basePath string, options ...IndexerOption) (*Indexer, error)

NewIndexer with specified base path and list of IndexerOptions

func (*Indexer) Close ¶

func (i *Indexer) Close() error

Close currently opened index Except currently opened one (specified by HEAD file), other indexes will be clean up and removed, to keep index path clean

func (*Indexer) DocCount ¶

func (i *Indexer) DocCount() (uint64, error)

DocCount returns number of documents stored within the index

func (*Indexer) Index ¶

func (i *Indexer) Index() (string, error)

Index will create new index from scratch for all file entries Such that files generations and deletions are not required to be tracked To use newly created index, use OpenAndSwap with returned index name

func (*Indexer) IndexName ¶

func (i *Indexer) IndexName() (string, error)

IndexName returns current loaded index name If index not opened, ErrIndexNotOpened is returned

func (*Indexer) LastIndexed ¶

func (i *Indexer) LastIndexed() (time.Time, error)

LastIndexer returns modification time of the index, as the index will not be updated once indexed

func (*Indexer) Open ¶

func (i *Indexer) Open() error

Open HEAD file specified index to be available for search and querying If HEAD file is not found, ErrIndexHeadDoesNotExist will returned If already opened, open again will simply check for the latest index specified in HEAD file and swap for it

func (*Indexer) OpenAndSwap ¶

func (i *Indexer) OpenAndSwap(name string) error

OpenAndSwap writes specified index to HEAD file, open and swap it with current index If same named index is already opened, only HEAD file will be overwritten again, no index will be swapped If no index is loaded, it will create/update HEAD file with specified index, open and load it

func (*Indexer) Search ¶

func (i *Indexer) Search(term string) (*bleve.SearchResult, error)

Search index with specified term and returns search result accordingly

func (*Indexer) SearchWith ¶

func (i *Indexer) SearchWith(req *bleve.SearchRequest) (*bleve.SearchResult, error)

SearchWith for custom bleve search request for the underlying index

type IndexerOption ¶

type IndexerOption func(*Indexer)

IndexerOption for options on indexing setup

func WithLocation ¶

func WithLocation(path string, option LocationOption) IndexerOption

WithLocation allows specificing directory location and options for traversing it

type LocationOption ¶

type LocationOption struct {

	// Filters for files and directories from the location path
	Filters []Filter

	// Ignores is list of gitignore patterns for ignoring files and directories
	// It allows nested string structures
	Ignores []interface{}
}

LocationOption of options on traversing the specified directory location tree

Directories ¶

Path Synopsis
cmd
fzd
Ignorer package for fzd, which wraps github.com/sabhiram/go-gitignore package for support of nested structure for gitignore styled strings
Ignorer package for fzd, which wraps github.com/sabhiram/go-gitignore package for support of nested structure for gitignore styled strings
Walker package for fzd, which wraps github.com/karrick/godirwalk package for more similar interface as filepath.Walk
Walker package for fzd, which wraps github.com/karrick/godirwalk package for more similar interface as filepath.Walk

Jump to

Keyboard shortcuts

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