Rename Single -> Singleton
- Remove some possible absolutely path nightmares
This commit is contained in:
parent
d97e826265
commit
7bc9a4de1e
6 changed files with 21 additions and 15 deletions
|
@ -75,9 +75,11 @@ func generateTestOutput(cmdData *CmdData, data *tplData) error {
|
||||||
return nil
|
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 {
|
if cmdData.SingleTemplates == nil {
|
||||||
return errors.New("No single templates located for generation")
|
return errors.New("No singleton templates located for generation")
|
||||||
}
|
}
|
||||||
|
|
||||||
tplData := &tplData{
|
tplData := &tplData{
|
||||||
|
@ -111,9 +113,11 @@ func generateSinglesOutput(cmdData *CmdData) error {
|
||||||
return nil
|
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 {
|
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{
|
tplData := &tplData{
|
||||||
|
|
|
@ -14,12 +14,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
templatesDirectory = "/cmds/templates"
|
templatesDirectory = "cmds/templates"
|
||||||
templatesSinglesDirectory = "/cmds/templates/singles"
|
templatesSinglesDirectory = "cmds/templates/singleton"
|
||||||
|
|
||||||
templatesTestDirectory = "/cmds/templates_test"
|
templatesTestDirectory = "cmds/templates_test"
|
||||||
templatesSinglesTestDirectory = "/cmds/templates_test/singles"
|
templatesSinglesTestDirectory = "cmds/templates_test/singleton"
|
||||||
templatesTestMainDirectory = "/cmds/templates_test/main_test"
|
templatesTestMainDirectory = "cmds/templates_test/main_test"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LoadTemplates loads all template folders into the cmdData object.
|
// 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.
|
// run executes the sqlboiler templates and outputs them to files.
|
||||||
func (c *CmdData) run(includeTests bool) error {
|
func (c *CmdData) run(includeTests bool) error {
|
||||||
if err := generateSinglesOutput(c); err != nil {
|
if err := generateSingletonOutput(c); err != nil {
|
||||||
return fmt.Errorf("Unable to generate single templates output: %s", err)
|
return fmt.Errorf("Unable to generate singleton template output: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if includeTests {
|
if includeTests {
|
||||||
|
@ -134,8 +134,8 @@ func (c *CmdData) run(includeTests bool) error {
|
||||||
return fmt.Errorf("Unable to generate TestMain output: %s", err)
|
return fmt.Errorf("Unable to generate TestMain output: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := generateSinglesTestOutput(c); err != nil {
|
if err := generateSingletonTestOutput(c); err != nil {
|
||||||
return fmt.Errorf("Unable to generate single test templates output: %s", err)
|
return fmt.Errorf("Unable to generate singleton test template output: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,9 @@ func TestTemplates(t *testing.T) {
|
||||||
t.Errorf("Templates is empty.")
|
t.Errorf("Templates is empty.")
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdData.SingleTemplates, err = loadTemplates("templates/singles")
|
cmdData.SingleTemplates, err = loadTemplates("templates/singleton")
|
||||||
if err != nil {
|
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 {
|
if len(cmdData.SingleTemplates) == 0 {
|
||||||
|
|
|
@ -52,6 +52,7 @@ type imports struct {
|
||||||
thirdparty importList
|
thirdparty importList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PostgresCfg configures a postgres database
|
||||||
type PostgresCfg struct {
|
type PostgresCfg struct {
|
||||||
User string `toml:"user"`
|
User string `toml:"user"`
|
||||||
Pass string `toml:"pass"`
|
Pass string `toml:"pass"`
|
||||||
|
@ -60,6 +61,7 @@ type PostgresCfg struct {
|
||||||
DBName string `toml:"dbname"`
|
DBName string `toml:"dbname"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Config is loaded from a file
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Postgres PostgresCfg `toml:"postgres"`
|
Postgres PostgresCfg `toml:"postgres"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue