From 7bc9a4de1e185e8d48b7acdf05c7965b8ae5daf8 Mon Sep 17 00:00:00 2001 From: Aaron L Date: Sat, 11 Jun 2016 15:17:47 -0700 Subject: [PATCH] Rename Single -> Singleton - Remove some possible absolutely path nightmares --- cmds/output.go | 12 ++++++++---- cmds/sqlboiler.go | 18 +++++++++--------- cmds/sqlboiler_test.go | 4 ++-- .../{singles => singleton}/helpers.tpl | 0 .../{singles => singleton}/helper_funcs.tpl | 0 cmds/types.go | 2 ++ 6 files changed, 21 insertions(+), 15 deletions(-) rename cmds/templates/{singles => singleton}/helpers.tpl (100%) rename cmds/templates_test/{singles => singleton}/helper_funcs.tpl (100%) diff --git a/cmds/output.go b/cmds/output.go index edacd0d..ac530d8 100644 --- a/cmds/output.go +++ b/cmds/output.go @@ -75,9 +75,11 @@ func generateTestOutput(cmdData *CmdData, data *tplData) error { return nil } -func generateSinglesOutput(cmdData *CmdData) error { +// generateSingletonOutput processes the templates that should only be run +// one time. +func generateSingletonOutput(cmdData *CmdData) error { if cmdData.SingleTemplates == nil { - return errors.New("No single templates located for generation") + return errors.New("No singleton templates located for generation") } tplData := &tplData{ @@ -111,9 +113,11 @@ func generateSinglesOutput(cmdData *CmdData) error { return nil } -func generateSinglesTestOutput(cmdData *CmdData) error { +// generateSingletonTestOutput processes the templates that should only be run +// one time. +func generateSingletonTestOutput(cmdData *CmdData) error { if cmdData.SingleTestTemplates == nil { - return errors.New("No single test templates located for generation") + return errors.New("No singleton test templates located for generation") } tplData := &tplData{ diff --git a/cmds/sqlboiler.go b/cmds/sqlboiler.go index a01f15f..60e91f6 100644 --- a/cmds/sqlboiler.go +++ b/cmds/sqlboiler.go @@ -14,12 +14,12 @@ import ( ) const ( - templatesDirectory = "/cmds/templates" - templatesSinglesDirectory = "/cmds/templates/singles" + templatesDirectory = "cmds/templates" + templatesSinglesDirectory = "cmds/templates/singleton" - templatesTestDirectory = "/cmds/templates_test" - templatesSinglesTestDirectory = "/cmds/templates_test/singles" - templatesTestMainDirectory = "/cmds/templates_test/main_test" + templatesTestDirectory = "cmds/templates_test" + templatesSinglesTestDirectory = "cmds/templates_test/singleton" + templatesTestMainDirectory = "cmds/templates_test/main_test" ) // LoadTemplates loads all template folders into the cmdData object. @@ -125,8 +125,8 @@ func (c *CmdData) SQLBoilerRun(cmd *cobra.Command, args []string) error { // run executes the sqlboiler templates and outputs them to files. func (c *CmdData) run(includeTests bool) error { - if err := generateSinglesOutput(c); err != nil { - return fmt.Errorf("Unable to generate single templates output: %s", err) + if err := generateSingletonOutput(c); err != nil { + return fmt.Errorf("Unable to generate singleton template output: %s", err) } if includeTests { @@ -134,8 +134,8 @@ func (c *CmdData) run(includeTests bool) error { return fmt.Errorf("Unable to generate TestMain output: %s", err) } - if err := generateSinglesTestOutput(c); err != nil { - return fmt.Errorf("Unable to generate single test templates output: %s", err) + if err := generateSingletonTestOutput(c); err != nil { + return fmt.Errorf("Unable to generate singleton test template output: %s", err) } } diff --git a/cmds/sqlboiler_test.go b/cmds/sqlboiler_test.go index 8f42c44..9482498 100644 --- a/cmds/sqlboiler_test.go +++ b/cmds/sqlboiler_test.go @@ -99,9 +99,9 @@ func TestTemplates(t *testing.T) { t.Errorf("Templates is empty.") } - cmdData.SingleTemplates, err = loadTemplates("templates/singles") + cmdData.SingleTemplates, err = loadTemplates("templates/singleton") if err != nil { - t.Fatalf("Unable to initialize single templates: %s", err) + t.Fatalf("Unable to initialize singleton templates: %s", err) } if len(cmdData.SingleTemplates) == 0 { diff --git a/cmds/templates/singles/helpers.tpl b/cmds/templates/singleton/helpers.tpl similarity index 100% rename from cmds/templates/singles/helpers.tpl rename to cmds/templates/singleton/helpers.tpl diff --git a/cmds/templates_test/singles/helper_funcs.tpl b/cmds/templates_test/singleton/helper_funcs.tpl similarity index 100% rename from cmds/templates_test/singles/helper_funcs.tpl rename to cmds/templates_test/singleton/helper_funcs.tpl diff --git a/cmds/types.go b/cmds/types.go index ec6e716..2445f03 100644 --- a/cmds/types.go +++ b/cmds/types.go @@ -52,6 +52,7 @@ type imports struct { thirdparty importList } +// PostgresCfg configures a postgres database type PostgresCfg struct { User string `toml:"user"` Pass string `toml:"pass"` @@ -60,6 +61,7 @@ type PostgresCfg struct { DBName string `toml:"dbname"` } +// Config is loaded from a file type Config struct { Postgres PostgresCfg `toml:"postgres"` }