Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add option -ignore-paths #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion cmd/misspell/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"os"
"path/filepath"
"regexp"
"runtime"
"strings"
"text/template"
Expand Down Expand Up @@ -106,6 +107,7 @@ func main() {
outFlag = flag.String("o", "stdout", "output file or [stderr|stdout|]")
format = flag.String("f", "", "'csv', 'sqlite3' or custom Golang template for output")
ignores = flag.String("i", "", "ignore the following corrections, comma separated")
ignorePaths = flag.String("ignore-paths", "", "ignore the following paths, RE")
locale = flag.String("locale", "", "Correct spellings using locale perferances for US or UK. Default is to use a neutral variety of English. Setting locale to US will correct the British spelling of 'colour' to 'color'")
mode = flag.String("source", "auto", "Source mode: auto=guess, go=golang source, text=plain or markdown-like text")
debugFlag = flag.Bool("debug", false, "Debug matching, very slow")
Expand All @@ -116,6 +118,11 @@ func main() {
)
flag.Parse()

ignorePathsRE, err := regexp.Compile(*ignorePaths)
if err != nil {
log.Fatalf("Failed to parse the regular expression in ignore-paths: %v.", err)
}

if *showVersion {
fmt.Println(version)
return
Expand Down Expand Up @@ -301,7 +308,7 @@ func main() {

for _, filename := range args {
filepath.Walk(filename, func(path string, info os.FileInfo, err error) error {
if err == nil && !info.IsDir() {
if err == nil && !info.IsDir() && (*ignorePaths == "" || !ignorePathsRE.MatchString(path)) {
c <- path
}
return nil
Expand Down