diff --git a/main.go b/main.go index 685de06..622d028 100644 --- a/main.go +++ b/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 diff --git a/sqlboiler.go b/sqlboiler.go index 042dffd..2faf34f 100644 --- a/sqlboiler.go +++ b/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 }