Fixed the same bugs I already fixed (again)
This commit is contained in:
parent
57e20dfd72
commit
6ee58a6529
2 changed files with 6 additions and 9 deletions
11
main.go
11
main.go
|
@ -7,7 +7,6 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -46,11 +45,11 @@ func main() {
|
||||||
|
|
||||||
// Set up the cobra root command
|
// Set up the cobra root command
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "sqlboiler [options] <driver>",
|
Use: "sqlboiler <driver>",
|
||||||
Short: "SQL Boiler generates boilerplate structs and statements",
|
Short: "SQL Boiler generates boilerplate structs and statements",
|
||||||
Long: "SQL Boiler generates boilerplate structs and statements from template files.\n" +
|
Long: "SQL Boiler generates boilerplate structs and statements from template files.\n" +
|
||||||
`Complete documentation is available at http://github.com/nullbio/sqlboiler`,
|
`Complete documentation is available at http://github.com/nullbio/sqlboiler`,
|
||||||
Example: `sqlboiler -o mymodels -p mymodelpackage postgres`,
|
Example: `sqlboiler postgres -o models -p models`,
|
||||||
PreRunE: preRun,
|
PreRunE: preRun,
|
||||||
RunE: run,
|
RunE: run,
|
||||||
PostRunE: postRun,
|
PostRunE: postRun,
|
||||||
|
@ -58,8 +57,8 @@ func main() {
|
||||||
|
|
||||||
// Set up the cobra root command flags
|
// Set up the cobra root command flags
|
||||||
rootCmd.PersistentFlags().StringSliceP("tables", "t", nil, "Tables to generate models for, all tables if empty")
|
rootCmd.PersistentFlags().StringSliceP("tables", "t", nil, "Tables to generate models for, all tables if empty")
|
||||||
rootCmd.PersistentFlags().StringP("output", "o", "output", "The name of the folder to output to")
|
rootCmd.PersistentFlags().StringP("output", "o", "models", "The name of the folder to output to")
|
||||||
rootCmd.PersistentFlags().StringP("pkgname", "p", "model", "The name you wish to assign to your generated package")
|
rootCmd.PersistentFlags().StringP("pkgname", "p", "models", "The name you wish to assign to your generated package")
|
||||||
|
|
||||||
viper.BindPFlags(rootCmd.PersistentFlags())
|
viper.BindPFlags(rootCmd.PersistentFlags())
|
||||||
|
|
||||||
|
@ -111,8 +110,6 @@ func preRun(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spew.Dump(cmdConfig)
|
|
||||||
|
|
||||||
cmdState, err = New(cmdConfig)
|
cmdState, err = New(cmdConfig)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ func disableTriggers() error {
|
||||||
var stmts []string
|
var stmts []string
|
||||||
|
|
||||||
{{range .Tables}}
|
{{range .Tables}}
|
||||||
stmts = append(stmts, `ALTER TABLE {{.}} DISABLE TRIGGER ALL;`)
|
stmts = append(stmts, `ALTER TABLE {{.Name}} DISABLE TRIGGER ALL;`)
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
|
||||||
if len(stmts) == 0 {
|
if len(stmts) == 0 {
|
||||||
|
@ -125,7 +125,7 @@ func LoadConfigFile(filename string) error {
|
||||||
// generated sqlboiler ORM package.
|
// generated sqlboiler ORM package.
|
||||||
func setup() error {
|
func setup() error {
|
||||||
// Load the config file in the parent directory.
|
// Load the config file in the parent directory.
|
||||||
err := LoadConfigFile("../config.toml")
|
err := LoadConfigFile("../sqlboiler.toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to load config file: %s", err)
|
return fmt.Errorf("Unable to load config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue