cmd

package
v0.0.0-...-64e2a4b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Build   string
	Version string
)
View Source
var RootCmd = &cobra.Command{
	Use:   "dbgen",
	Short: "Generate a set of go types and protobuf files from a set of database tables",
	Long: `
Generate a set of go types and protobuf files from a set of database tables

Example:

	dbgen --database foo --dir ./gen

`,
	Run: func(cmd *cobra.Command, args []string) {
		if database == "" {
			fmt.Println("database name is required")
			os.Exit(1)
		}
		if dir == "" {
			fmt.Println("directory name is required")
			os.Exit(1)
		}

		dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", username, password, hostname, port, database)
		db, err := sqlx.Connect("mysql", dsn)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		defer db.Close()

		if err := gen.Generate(db, database, pkg, dir); err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL