Finished most of the stripping
This commit is contained in:
parent
c74ed4e75f
commit
27cafdd2fb
15 changed files with 401 additions and 723 deletions
45
main.go
45
main.go
|
@ -10,15 +10,52 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/pobri19/sqlboiler/cmds"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Load the config.toml file
|
||||
cmds.LoadConfigFile("config.toml")
|
||||
var err error
|
||||
cmdData := &cmds.CmdData{}
|
||||
|
||||
// Load the "config.toml" global config
|
||||
err = cmdData.LoadConfigFile("config.toml")
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to load config file: %s\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
// Load all templates
|
||||
err = cmdData.LoadTemplates()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to load templates: %s\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
// Set up the cobra root command
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "sqlboiler",
|
||||
Short: "SQL Boiler generates boilerplate structs and statements",
|
||||
Long: "SQL Boiler generates boilerplate structs and statements from the template files.\n" +
|
||||
`Complete documentation is available at http://github.com/pobri19/sqlboiler`,
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
return cmdData.SQLBoilerPreRun(cmd, args)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return cmdData.SQLBoilerRun(cmd, args)
|
||||
},
|
||||
PostRunE: func(cmd *cobra.Command, args []string) error {
|
||||
return cmdData.SQLBoilerPostRun(cmd, args)
|
||||
},
|
||||
}
|
||||
|
||||
// Set up the cobra root command flags
|
||||
rootCmd.PersistentFlags().StringP("driver", "d", "", "The name of the driver in your config.toml (mandatory)")
|
||||
rootCmd.PersistentFlags().StringP("table", "t", "", "A comma seperated list of table names")
|
||||
rootCmd.PersistentFlags().StringP("folder", "f", "output", "The name of the output folder")
|
||||
rootCmd.PersistentFlags().StringP("pkgname", "p", "model", "The name you wish to assign to your generated package")
|
||||
|
||||
// Execute SQLBoiler
|
||||
if err := cmds.SQLBoiler.Execute(); err != nil {
|
||||
fmt.Printf("Failed to execute SQLBoiler: %s", err)
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue