Fix some configuration bits.
- Refix the panics that were occuring (almost all of them).
This commit is contained in:
parent
56234e37a1
commit
e0f461014b
2 changed files with 19 additions and 7 deletions
7
main.go
7
main.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
@ -62,7 +63,7 @@ func main() {
|
||||||
viper.BindPFlags(rootCmd.PersistentFlags())
|
viper.BindPFlags(rootCmd.PersistentFlags())
|
||||||
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
fmt.Println("Failed to execute sqlboiler command:", err)
|
fmt.Println(err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +79,7 @@ func preRun(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
cmdConfig.DriverName = args[0]
|
cmdConfig.DriverName = args[0]
|
||||||
cmdConfig.TableName = viper.GetString("table")
|
cmdConfig.TableName = viper.GetString("table")
|
||||||
cmdConfig.OutFolder = viper.GetString("folder")
|
cmdConfig.OutFolder = viper.GetString("output")
|
||||||
cmdConfig.PkgName = viper.GetString("pkgname")
|
cmdConfig.PkgName = viper.GetString("pkgname")
|
||||||
|
|
||||||
if len(cmdConfig.DriverName) == 0 {
|
if len(cmdConfig.DriverName) == 0 {
|
||||||
|
@ -98,6 +99,8 @@ func preRun(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spew.Dump(cmdConfig)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
cmdState, err = New(cmdConfig)
|
cmdState, err = New(cmdConfig)
|
||||||
return err
|
return err
|
||||||
|
|
19
sqlboiler.go
19
sqlboiler.go
|
@ -13,11 +13,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
templatesDirectory = "cmds/templates"
|
templatesDirectory = "templates"
|
||||||
templatesSingletonDirectory = "cmds/templates/singleton"
|
templatesSingletonDirectory = "templates/singleton"
|
||||||
|
|
||||||
templatesTestDirectory = "cmds/templates_test"
|
templatesTestDirectory = "templates_test"
|
||||||
templatesSingletonTestDirectory = "cmds/templates_test/singleton"
|
templatesSingletonTestDirectory = "templates_test/singleton"
|
||||||
|
|
||||||
|
templatesTestMainDirectory = "templates_test/main_test"
|
||||||
)
|
)
|
||||||
|
|
||||||
// State holds the global data needed by most pieces to run
|
// State holds the global data needed by most pieces to run
|
||||||
|
@ -37,7 +39,9 @@ type State struct {
|
||||||
|
|
||||||
// New creates a new state based off of the config
|
// New creates a new state based off of the config
|
||||||
func New(config *Config) (*State, error) {
|
func New(config *Config) (*State, error) {
|
||||||
s := &State{}
|
s := &State{
|
||||||
|
Config: config,
|
||||||
|
}
|
||||||
|
|
||||||
err := s.initDriver(config.DriverName)
|
err := s.initDriver(config.DriverName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -147,6 +151,11 @@ func (s *State) initTemplates() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.TestMainTemplate, err = loadTemplate(templatesTestMainDirectory, s.Config.DriverName+"_main.tpl")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue