You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-11
Original file line number
Diff line number
Diff line change
@@ -43,25 +43,28 @@ your.txt:42:10 found "langauge" a misspelling of "language"
43
43
$ misspell -help
44
44
Usage of misspell:
45
45
-debug
46
-
Debug matching, very slow
46
+
Debug matching, very slow
47
+
-dict string
48
+
User defined corrections file path (.csv). CSV format: typo,fix
47
49
-error
48
-
Exit with 2 if misspelling found
50
+
Exit with 2 if misspelling found
49
51
-f string
50
-
'csv', 'sqlite3' or custom Golang template for output
52
+
'csv', 'sqlite3' or custom Golang template for output
51
53
-i string
52
-
ignore the following corrections, comma-separated
54
+
ignore the following corrections, comma-separated
53
55
-j int
54
-
Number of workers, 0 = number of CPUs
56
+
Number of workers, 0 = number of CPUs
55
57
-legal
56
-
Show legal information and exit
58
+
Show legal information and exit
57
59
-locale string
58
-
Correct spellings using locale preferences 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'
60
+
Correct spellings using locale preferences 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'
59
61
-o string
60
-
output file or [stderr|stdout|] (default "stdout")
61
-
-qDo not emit misspelling output
62
+
output file or [stderr|stdout|] (default "stdout")
63
+
-qDo not emit misspelling output
62
64
-source string
63
-
Source mode: auto=guess, go=golang source, text=plain or markdown-like text (default "auto")
64
-
-w Overwrite file with corrections (default is just to display)
65
+
Source mode: text (default), go (comments only) (default "text")
66
+
-v Show version and exit
67
+
-w Overwrite file with corrections (default is just to display)
//nolint:funlen,nestif,gocognit,gocyclo,maintidx // TODO(ldez) must be fixed.
106
107
funcmain() {
107
108
t:=time.Now()
109
+
108
110
var (
109
-
workers=flag.Int("j", 0, "Number of workers, 0 = number of CPUs")
110
-
writeit=flag.Bool("w", false, "Overwrite file with corrections (default is just to display)")
111
-
quietFlag=flag.Bool("q", false, "Do not emit misspelling output")
112
-
outFlag=flag.String("o", "stdout", "output file or [stderr|stdout|]")
113
-
format=flag.String("f", "", "'csv', 'sqlite3' or custom Golang template for output")
114
-
ignores=flag.String("i", "", "ignore the following corrections, comma-separated")
115
-
locale=flag.String("locale", "", "Correct spellings using locale preferences 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'")
116
-
mode=flag.String("source", "text", "Source mode: text (default), go (comments only)")
117
-
debugFlag=flag.Bool("debug", false, "Debug matching, very slow")
118
-
exitError=flag.Bool("error", false, "Exit with 2 if misspelling found")
119
-
showVersion=flag.Bool("v", false, "Show version and exit")
111
+
workers=flag.Int("j", 0, "Number of workers, 0 = number of CPUs")
112
+
writeit=flag.Bool("w", false, "Overwrite file with corrections (default is just to display)")
113
+
quietFlag=flag.Bool("q", false, "Do not emit misspelling output")
114
+
outFlag=flag.String("o", "stdout", "output file or [stderr|stdout|]")
115
+
format=flag.String("f", "", "'csv', 'sqlite3' or custom Golang template for output")
116
+
ignores=flag.String("i", "", "ignore the following corrections, comma-separated")
locale=flag.String("locale", "", "Correct spellings using locale preferences 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'")
119
+
mode=flag.String("source", "text", "Source mode: text (default), go (comments only)")
120
+
debugFlag=flag.Bool("debug", false, "Debug matching, very slow")
121
+
exitError=flag.Bool("error", false, "Exit with 2 if misspelling found")
122
+
showVersion=flag.Bool("v", false, "Show version and exit")
120
123
121
124
showLegal=flag.Bool("legal", false, "Show legal information and exit")
122
125
)
@@ -140,6 +143,7 @@ func main() {
140
143
Replacements: misspell.DictMain,
141
144
Debug: *debugFlag,
142
145
}
146
+
143
147
//
144
148
// Figure out regional variations
145
149
//
@@ -156,6 +160,32 @@ func main() {
156
160
log.Fatalf("Unknown locale: %q", *locale)
157
161
}
158
162
163
+
//
164
+
// Load user defined words
165
+
//
166
+
if*userDictPath!="" {
167
+
file, err:=os.Open(*userDictPath)
168
+
iferr!=nil {
169
+
log.Fatalf("Failed to load user defined corrections: %v, err: %v", *userDictPath, err)
170
+
}
171
+
deferfile.Close()
172
+
173
+
reader:=csv.NewReader(file)
174
+
reader.FieldsPerRecord=2
175
+
176
+
data, err:=reader.ReadAll()
177
+
iferr!=nil {
178
+
log.Fatalf("reading user defined corrections: %v", err)
0 commit comments