Skip to content
This repository was archived by the owner on Jul 11, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmd/cindex/cindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Options:
skip indexing a file if it has more than this ratio of invalid UTF-8 sequences (Default: %v)
-exclude FILE
path to file containing a list of file patterns to exclude from indexing
-filelist FILE
path to file containing a list of file paths to index

cindex prepares the trigram index for use by csearch. The index is the
file named by $CSEARCHINDEX, or else $HOME/.csearchindex.
Expand Down Expand Up @@ -94,6 +96,7 @@ var (
logSkipFlag = flag.Bool("logskip", false, "print why a file was skipped from indexing")
noFollowSymlinksFlag = flag.Bool("no-follow-symlinks", false, "do not follow symlinked files and directories")
exclude = flag.String("exclude", "", "path to file containing a list of file patterns to exclude from indexing")
fileList = flag.String("filelist", "", "path to file containing a list of file paths to index")
// Tuning variables for detecting text files.
// A file is assumed not to be text files (and thus not indexed) if
// 1) if it contains an invalid UTF-8 sequences
Expand Down Expand Up @@ -283,6 +286,23 @@ func main() {
}
}

if *fileList != "" {
var fileListPath string
if (*fileList)[:2] == "~/" {
fileListPath = filepath.Join(index.HomeDir(), (*fileList)[2:])
} else {
fileListPath = *fileList
}
if *logSkipFlag {
log.Printf("Loading fileList patterns from %s", fileListPath)
}
data, err := ioutil.ReadFile(fileListPath)
if err != nil {
log.Fatal(err)
}
args = append(args, strings.Split(string(data), "\n")...)
}

if len(args) == 0 {
ix := index.Open(index.File())
for _, arg := range ix.Paths() {
Expand Down