package main

import (
	"log"

	"github.com/griffithsh/sql-squish/database"
)

func main() {
	concatted, err := inputStdin()

	if err != nil {
		log.Fatal(err)
	}
	d, err := database.FromString(concatted)
	if err != nil {
		log.Fatal(err)
	}

	outputStdout(d)
}

package main

import (
	"bufio"
	"fmt"
	"log"
	"os"

	"github.com/griffithsh/sql-squish/database"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var concatted string
	for scanner.Scan() {
		concatted = concatted + scanner.Text()
	}
	d, err := database.FromString(concatted)
	if err != nil {
		log.Fatal(err)
	}
	for _, t := range d.Tables {
		fmt.Println(t.String())
	}
	// files, err := db.AsSQL()
	// if err != nil {
	// 	log.Fatal(err)
	// }
	// for file := range files {
	// 	fmt.Print(file)
	// }
}

--- 
+++ 
@@ -1,33 +1,21 @@
 package main
 
 import (
-	"bufio"
-	"fmt"
 	"log"
-	"os"
 
 	"github.com/griffithsh/sql-squish/database"
 )
 
 func main() {
-	scanner := bufio.NewScanner(os.Stdin)
+	concatted, err := inputStdin()
 
-	var concatted string
-	for scanner.Scan() {
-		concatted = concatted + scanner.Text()
+	if err != nil {
+		log.Fatal(err)
 	}
 	d, err := database.FromString(concatted)
 	if err != nil {
 		log.Fatal(err)
 	}
-	for _, t := range d.Tables {
-		fmt.Println(t.String())
-	}
-	// files, err := db.AsSQL()
-	// if err != nil {
-	// 	log.Fatal(err)
-	// }
-	// for file := range files {
-	// 	fmt.Print(file)
-	// }
+
+	outputStdout(d)
 }
Use input and output functions in sqlite-squish

Now that I have a structure of input and output, I can leverage those in
the main cli file to keep control flow clear.
