Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pull request pipeline
name: pull request pipeline

on:
pull_request:
Expand All @@ -16,5 +16,3 @@ jobs:

- name: Test
uses: robherley/go-test-action@v0
with:
omit: "pie"
4 changes: 2 additions & 2 deletions fileOperations.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func readFile(filePath string) ([]string, error) {
if err.Error() == "EOF" {
break
}
fmt.Println("Error reading file: ", err)
fmt.Println("error reading file: ", err)
return nil, err
}

Expand Down Expand Up @@ -60,5 +60,5 @@ func saveToFile(filePath string, data []string) {
return
}

fmt.Println("data written successfully.")
fmt.Println("converted SQL is saved to " + filePath)
}
28 changes: 16 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,7 @@ func main() {
parseFlags()

if cmdLineArgs.fileName != "" {
out, err := readFile(cmdLineArgs.fileName)
if err != nil {
fmt.Println("error happened", err)
os.Exit(1)
}

converted := ConvertSingleLineToMultilineSQLFromFile(out)
if cmdLineArgs.outputFileName != "" {
saveToFile(cmdLineArgs.outputFileName, converted)
} else {
fmt.Println(strings.Join(converted, ""))
}
convertDataFromFile()
os.Exit(0)
}

Expand All @@ -43,3 +32,18 @@ func main() {
fmt.Println(output)
}
}

func convertDataFromFile() {
out, err := readFile(cmdLineArgs.fileName)
if err != nil {
fmt.Println("error happened", err)
os.Exit(1)
}

converted := ConvertSingleLineToMultilineSQLFromFile(out)
if cmdLineArgs.outputFileName != "" {
saveToFile(cmdLineArgs.outputFileName, converted)
} else {
fmt.Println(strings.Join(converted, ""))
}
}
Loading