@@ -23,6 +23,7 @@ import (
23
23
"io"
24
24
"os"
25
25
"path"
26
+ "runtime"
26
27
"strings"
27
28
28
29
// Caltech Library packages
@@ -94,7 +95,10 @@ zero. Supports exact match as well as some Levenshtein matching.
94
95
: set the edit distance thresh hold for match, default 0
95
96
96
97
-nl, -newline
97
- : include trailing newline from output
98
+ : include trailing newline from output for end of file (EOF)
99
+
100
+ -crlf
101
+ : use CRLF for end of line (EOL) on write, defaults to true for Windows
98
102
99
103
-o, -output
100
104
: output filename
@@ -182,6 +186,7 @@ You can also search for phrases in columns.
182
186
delimiter string
183
187
lazyQuotes bool
184
188
trimLeadingSpace bool
189
+ useCRLF bool
185
190
)
186
191
187
192
func main () {
@@ -190,6 +195,7 @@ func main() {
190
195
license := datatools .LicenseText
191
196
releaseDate := datatools .ReleaseDate
192
197
releaseHash := datatools .ReleaseHash
198
+ useCRLF = (runtime .GOOS == "windows" )
193
199
194
200
// Basic Options
195
201
flag .BoolVar (& showHelp , "help" , false , "display help" )
@@ -224,6 +230,7 @@ func main() {
224
230
flag .BoolVar (& trimSpaces , "trimspaces" , false , "trim spaces around cell values before comparing" )
225
231
flag .BoolVar (& lazyQuotes , "use-lazy-quotes" , false , "use lazy quotes on CSV input" )
226
232
flag .BoolVar (& trimLeadingSpace , "trim-leading-space" , false , "trim leadings space in field(s) for CSV input" )
233
+ flag .BoolVar (& useCRLF , "crlf" , useCRLF , "use CRLF for end of line (EOL) on write" )
227
234
228
235
// Parse env and options
229
236
flag .Parse ()
@@ -300,6 +307,7 @@ func main() {
300
307
csvIn .LazyQuotes = lazyQuotes
301
308
csvIn .TrimLeadingSpace = trimLeadingSpace
302
309
csvOut := csv .NewWriter (out )
310
+ csvOut .UseCRLF = useCRLF
303
311
if delimiter != "" {
304
312
csvIn .Comma = datatools .NormalizeDelimiterRune (delimiter )
305
313
csvOut .Comma = datatools .NormalizeDelimiterRune (delimiter )
0 commit comments