Remove pointers to L, not needed
* Add no-tests flag
This commit is contained in:
parent
530aec1e16
commit
4b1c934751
6 changed files with 21 additions and 16 deletions
|
@ -7,6 +7,7 @@ type Config struct {
|
|||
OutFolder string
|
||||
BaseDir string
|
||||
ExcludeTables []string
|
||||
NoTests bool
|
||||
NoHooks bool
|
||||
NoAutoTimestamps bool
|
||||
|
||||
|
|
2
main.go
2
main.go
|
@ -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"),
|
||||
}
|
||||
|
|
|
@ -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,6 +159,7 @@ func (s *State) initTemplates() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !s.Config.NoTests {
|
||||
s.TestTemplates, err = loadTemplates(filepath.Join(basePath, templatesTestDirectory))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -173,6 +174,7 @@ func (s *State) initTemplates() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -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 -}}
|
||||
}
|
||||
|
||||
|
|
|
@ -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}}
|
||||
|
||||
|
|
|
@ -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}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue