Remove pointers to L, not needed

* Add no-tests flag
This commit is contained in:
Patrick O'brien 2016-09-02 11:22:56 +10:00
parent 530aec1e16
commit 4b1c934751
6 changed files with 21 additions and 16 deletions

View file

@ -7,6 +7,7 @@ type Config struct {
OutFolder string
BaseDir string
ExcludeTables []string
NoTests bool
NoHooks bool
NoAutoTimestamps bool

View file

@ -65,6 +65,7 @@ func main() {
rootCmd.PersistentFlags().StringP("basedir", "b", "", "The base directory has the templates and templates_test folders")
rootCmd.PersistentFlags().StringSliceP("exclude", "x", nil, "Tables to be excluded from the generated package")
rootCmd.PersistentFlags().BoolP("debug", "d", false, "Debug mode prints stack traces on error")
rootCmd.PersistentFlags().BoolP("no-tests", "", false, "Disable generated go test files")
rootCmd.PersistentFlags().BoolP("no-hooks", "", false, "Disable hooks feature for your models")
rootCmd.PersistentFlags().BoolP("no-auto-timestamps", "", false, "Disable automatic timestamps for created_at/updated_at")
@ -106,6 +107,7 @@ func preRun(cmd *cobra.Command, args []string) error {
DriverName: driverName,
OutFolder: viper.GetString("output"),
PkgName: viper.GetString("pkgname"),
NoTests: viper.GetBool("no-tests"),
NoHooks: viper.GetBool("no-hooks"),
NoAutoTimestamps: viper.GetBool("no-auto-timestamps"),
}

View file

@ -91,7 +91,7 @@ func (s *State) Run(includeTests bool) error {
return errors.Wrap(err, "singleton template output")
}
if includeTests {
if !s.Config.NoTests && includeTests {
if err := generateTestMainOutput(s, singletonData); err != nil {
return errors.Wrap(err, "unable to generate TestMain output")
}
@ -124,7 +124,7 @@ func (s *State) Run(includeTests bool) error {
}
// Generate the test templates
if includeTests {
if !s.Config.NoTests && includeTests {
if err := generateTestOutput(s, data); err != nil {
return errors.Wrap(err, "unable to generate test output")
}
@ -159,19 +159,21 @@ func (s *State) initTemplates() error {
return err
}
s.TestTemplates, err = loadTemplates(filepath.Join(basePath, templatesTestDirectory))
if err != nil {
return err
}
if !s.Config.NoTests {
s.TestTemplates, err = loadTemplates(filepath.Join(basePath, templatesTestDirectory))
if err != nil {
return err
}
s.SingletonTestTemplates, err = loadTemplates(filepath.Join(basePath, templatesSingletonTestDirectory))
if err != nil {
return err
}
s.SingletonTestTemplates, err = loadTemplates(filepath.Join(basePath, templatesSingletonTestDirectory))
if err != nil {
return err
}
s.TestMainTemplate, err = loadTemplate(filepath.Join(basePath, templatesTestMainDirectory), s.Config.DriverName+"_main.tpl")
if err != nil {
return err
s.TestMainTemplate, err = loadTemplate(filepath.Join(basePath, templatesTestMainDirectory), s.Config.DriverName+"_main.tpl")
if err != nil {
return err
}
}
return nil

View file

@ -13,7 +13,7 @@ type {{$modelName}} struct {
{{- if .Table.IsJoinTable -}}
{{- else}}
R *{{$modelNameCamel}}R `boil:"-" json:"-" toml:"-" yaml:"-"`
L *{{$modelNameCamel}}L `boil:"-" json:"-" toml:"-" yaml:"-"`
L {{$modelNameCamel}}L `boil:"-" json:"-" toml:"-" yaml:"-"`
{{end -}}
}

View file

@ -6,7 +6,7 @@
{{- $slice := printf "%sSlice" .LocalTable.NameGo -}}
// Load{{.Function.Name}} allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (t *{{$varNameSingular}}L) Load{{.Function.Name}}(e boil.Executor, singular bool, {{$arg}} interface{}) error {
func ({{$varNameSingular}}L) Load{{.Function.Name}}(e boil.Executor, singular bool, {{$arg}} interface{}) error {
var slice []*{{.LocalTable.NameGo}}
var object *{{.LocalTable.NameGo}}

View file

@ -12,7 +12,7 @@
{{- $slice := printf "%sSlice" $txt.LocalTable.NameGo -}}
// Load{{$txt.Function.Name}} allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (t *{{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singular bool, {{$arg}} interface{}) error {
func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singular bool, {{$arg}} interface{}) error {
var slice []*{{$txt.LocalTable.NameGo}}
var object *{{$txt.LocalTable.NameGo}}