Made new core package to hold core of app

* This was primarily done so it can be used as a library in ABCWeb and
other apps.
This commit is contained in:
Patrick O'brien 2017-01-14 13:13:55 +10:00
parent ab01c9d234
commit 88cde8df0c
12 changed files with 18 additions and 17 deletions

View file

@ -1,4 +1,4 @@
package main package core
// Config for the running of the commands // Config for the running of the commands
type Config struct { type Config struct {

View file

@ -1,6 +1,6 @@
// Package sqlboiler has types and methods useful for generating code that // Package sqlboiler has types and methods useful for generating code that
// acts as a fully dynamic ORM might. // acts as a fully dynamic ORM might.
package main package core
import ( import (
"encoding/json" "encoding/json"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"bufio" "bufio"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"bytes" "bytes"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"reflect" "reflect"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"bufio" "bufio"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"bytes" "bytes"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"fmt" "fmt"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"sort" "sort"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"fmt" "fmt"

View file

@ -1,4 +1,4 @@
package main package core
import ( import (
"reflect" "reflect"

13
main.go
View file

@ -11,13 +11,14 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/vattle/sqlboiler/bdb/drivers" "github.com/vattle/sqlboiler/bdb/drivers"
"github.com/vattle/sqlboiler/core"
) )
const sqlBoilerVersion = "2.1.5" const sqlBoilerVersion = "2.1.5"
var ( var (
cmdState *State cmdState *core.State
cmdConfig *Config cmdConfig *core.Config
) )
func main() { func main() {
@ -122,7 +123,7 @@ func preRun(cmd *cobra.Command, args []string) error {
driverName := args[0] driverName := args[0]
cmdConfig = &Config{ cmdConfig = &core.Config{
DriverName: driverName, DriverName: driverName,
OutFolder: viper.GetString("output"), OutFolder: viper.GetString("output"),
Schema: viper.GetString("schema"), Schema: viper.GetString("schema"),
@ -163,7 +164,7 @@ func preRun(cmd *cobra.Command, args []string) error {
} }
if driverName == "postgres" { if driverName == "postgres" {
cmdConfig.Postgres = PostgresConfig{ cmdConfig.Postgres = core.PostgresConfig{
User: viper.GetString("postgres.user"), User: viper.GetString("postgres.user"),
Pass: viper.GetString("postgres.pass"), Pass: viper.GetString("postgres.pass"),
Host: viper.GetString("postgres.host"), Host: viper.GetString("postgres.host"),
@ -199,7 +200,7 @@ func preRun(cmd *cobra.Command, args []string) error {
} }
if driverName == "mysql" { if driverName == "mysql" {
cmdConfig.MySQL = MySQLConfig{ cmdConfig.MySQL = core.MySQLConfig{
User: viper.GetString("mysql.user"), User: viper.GetString("mysql.user"),
Pass: viper.GetString("mysql.pass"), Pass: viper.GetString("mysql.pass"),
Host: viper.GetString("mysql.host"), Host: viper.GetString("mysql.host"),
@ -240,7 +241,7 @@ func preRun(cmd *cobra.Command, args []string) error {
} }
} }
cmdState, err = New(cmdConfig) cmdState, err = core.New(cmdConfig)
return err return err
} }