diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 15ca14f..a8a83f4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,4 @@ -name: Pull request pipeline +name: pull request pipeline on: pull_request: @@ -16,5 +16,3 @@ jobs: - name: Test uses: robherley/go-test-action@v0 - with: - omit: "pie" diff --git a/fileOperations.go b/fileOperations.go index b26e173..37b36cb 100644 --- a/fileOperations.go +++ b/fileOperations.go @@ -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 } @@ -60,5 +60,5 @@ func saveToFile(filePath string, data []string) { return } - fmt.Println("data written successfully.") + fmt.Println("converted SQL is saved to " + filePath) } diff --git a/main.go b/main.go index 204541c..2657486 100644 --- a/main.go +++ b/main.go @@ -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) } @@ -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, "")) + } +}