Skip to content

Commit

Permalink
(Closed #10) Added RMNL(Remove newline) option
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Feb 8, 2021
1 parent fa81cdb commit 1bef7ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,6 +46,7 @@ func main() {
WithTimestamp: *withTimeOption,
Prefix: *prefixOption,
Suffix: *suffixOption,
RemoveNewLine: *rmnlOption,
}

// Running gee app
Expand Down
17 changes: 13 additions & 4 deletions pkg/gee/gee.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Options struct {
Suffix string
WithTimestamp bool
WithLine bool
RemoveLine bool
RemoveNewLine bool
TableMarkdown bool
TableHTML bool
Regex string
Expand Down

0 comments on commit 1bef7ef

Please sign in to comment.