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"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -62,7 +63,7 @@ func main() {
|
|||
viper.BindPFlags(rootCmd.PersistentFlags())
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println("Failed to execute sqlboiler command:", err)
|
||||
fmt.Println(err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +79,7 @@ func preRun(cmd *cobra.Command, args []string) error {
|
|||
|
||||
cmdConfig.DriverName = args[0]
|
||||
cmdConfig.TableName = viper.GetString("table")
|
||||
cmdConfig.OutFolder = viper.GetString("folder")
|
||||
cmdConfig.OutFolder = viper.GetString("output")
|
||||
cmdConfig.PkgName = viper.GetString("pkgname")
|
||||
|
||||
if len(cmdConfig.DriverName) == 0 {
|
||||
|
@ -98,6 +99,8 @@ func preRun(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
}
|
||||
|
||||
spew.Dump(cmdConfig)
|
||||
|
||||
var err error
|
||||
cmdState, err = New(cmdConfig)
|
||||
return err
|
||||
|
|
19
sqlboiler.go
19
sqlboiler.go
|
@ -13,11 +13,13 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
templatesDirectory = "cmds/templates"
|
||||
templatesSingletonDirectory = "cmds/templates/singleton"
|
||||
templatesDirectory = "templates"
|
||||
templatesSingletonDirectory = "templates/singleton"
|
||||
|
||||
templatesTestDirectory = "cmds/templates_test"
|
||||
templatesSingletonTestDirectory = "cmds/templates_test/singleton"
|
||||
templatesTestDirectory = "templates_test"
|
||||
templatesSingletonTestDirectory = "templates_test/singleton"
|
||||
|
||||
templatesTestMainDirectory = "templates_test/main_test"
|
||||
)
|
||||
|
||||
// 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
|
||||
func New(config *Config) (*State, error) {
|
||||
s := &State{}
|
||||
s := &State{
|
||||
Config: config,
|
||||
}
|
||||
|
||||
err := s.initDriver(config.DriverName)
|
||||
if err != nil {
|
||||
|
@ -147,6 +151,11 @@ func (s *State) initTemplates() error {
|
|||
return err
|
||||
}
|
||||
|
||||
s.TestMainTemplate, err = loadTemplate(templatesTestMainDirectory, s.Config.DriverName+"_main.tpl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue