From 1bef7efa76e9aa41be0cf3788e719d27f8d1093d Mon Sep 17 00:00:00 2001 From: hahwul Date: Tue, 9 Feb 2021 03:31:37 +0900 Subject: [PATCH] (Closed #10) Added RMNL(Remove newline) option --- main.go | 2 ++ pkg/gee/gee.go | 17 +++++++++++++---- pkg/model/options.go | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 9e51994..a6b3b89 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ func main() { withTimeOption := flag.Bool("with-time", false, "With timestamp") prefixOption := flag.String("prefix", "", "Prefix string") suffixOption := flag.String("suffix", "", "Suffix string") + rmnlOption := flag.Bool("rmnl", false, "Remove newline(\\r\\n)") flag.Parse() // Show version @@ -45,6 +46,7 @@ func main() { WithTimestamp: *withTimeOption, Prefix: *prefixOption, Suffix: *suffixOption, + RemoveNewLine: *rmnlOption, } // Running gee app diff --git a/pkg/gee/gee.go b/pkg/gee/gee.go index 3379a99..5a4f5d7 100644 --- a/pkg/gee/gee.go +++ b/pkg/gee/gee.go @@ -45,7 +45,11 @@ func Gee(options model.Options) { // Prefix and Suffix line = options.Prefix + l + options.Suffix - fmt.Println(line) + if options.RemoveNewLine { + fmt.Print(line) + } else { + fmt.Println(line) + } if (stdLine > options.ChunkedLine) && (options.ChunkedLine != 0) { ClosedFiles(files) for _, filename := range options.Files { @@ -60,9 +64,14 @@ func Gee(options model.Options) { stdPointer = stdPointer + 1 } for _, k := range files { - _, err := k.WriteString(line) - if err != nil { - + if options.RemoveNewLine { + _, err := k.WriteString(line) + if err != nil { + } + } else { + _, err := k.WriteString(line + "\r\n") + if err != nil { + } } } stdLine = stdLine + 1 diff --git a/pkg/model/options.go b/pkg/model/options.go index 9640089..59a1001 100644 --- a/pkg/model/options.go +++ b/pkg/model/options.go @@ -10,7 +10,7 @@ type Options struct { Suffix string WithTimestamp bool WithLine bool - RemoveLine bool + RemoveNewLine bool TableMarkdown bool TableHTML bool Regex string