Allow database URL to be specified via command line

This commit is contained in:
Adrian Macneil 2015-11-25 11:32:13 -08:00
parent 99a4f266e6
commit ece5d3cf0e
4 changed files with 36 additions and 9 deletions

13
main.go
View file

@ -11,6 +11,12 @@ import (
func main() {
loadDotEnv()
app := NewApp()
app.Run(os.Args)
}
// NewApp creates a new command line app
func NewApp() *cli.App {
app := cli.NewApp()
app.Name = "dbmate"
app.Usage = "A lightweight, framework-independent database migration tool."
@ -21,6 +27,11 @@ func main() {
Value: "./db/migrations",
Usage: "specify the directory containing migration files",
},
cli.StringFlag{
Name: "env, e",
Value: "DATABASE_URL",
Usage: "specify an environment variable containing the database URL",
},
}
app.Commands = []cli.Command{
@ -54,7 +65,7 @@ func main() {
},
}
app.Run(os.Args)
return app
}
type command func(*cli.Context) error