Allow setting flags via environment variables (#152)

This commit is contained in:
Adrian Macneil 2020-08-08 11:50:45 -07:00 committed by GitHub
parent a9aaaad1fb
commit 9e2d1b8c3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 14 deletions

22
main.go
View file

@ -48,27 +48,32 @@ func NewApp() *cli.App {
&cli.StringFlag{
Name: "migrations-dir",
Aliases: []string{"d"},
EnvVars: []string{"DBMATE_MIGRATIONS_DIR"},
Value: dbmate.DefaultMigrationsDir,
Usage: "specify the directory containing migration files",
},
&cli.StringFlag{
Name: "schema-file",
Aliases: []string{"s"},
EnvVars: []string{"DBMATE_SCHEMA_FILE"},
Value: dbmate.DefaultSchemaFile,
Usage: "specify the schema file location",
},
&cli.BoolFlag{
Name: "no-dump-schema",
Usage: "don't update the schema file on migrate/rollback",
Name: "no-dump-schema",
EnvVars: []string{"DBMATE_NO_DUMP_SCHEMA"},
Usage: "don't update the schema file on migrate/rollback",
},
&cli.BoolFlag{
Name: "wait",
Usage: "wait for the db to become available before executing the subsequent command",
Name: "wait",
EnvVars: []string{"DBMATE_WAIT"},
Usage: "wait for the db to become available before executing the subsequent command",
},
&cli.DurationFlag{
Name: "wait-timeout",
Usage: "timeout for --wait flag",
Value: dbmate.DefaultWaitTimeout,
Name: "wait-timeout",
EnvVars: []string{"DBMATE_WAIT_TIMEOUT"},
Usage: "timeout for --wait flag",
Value: dbmate.DefaultWaitTimeout,
},
}
@ -89,6 +94,7 @@ func NewApp() *cli.App {
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
EnvVars: []string{"DBMATE_VERBOSE"},
Usage: "print the result of each statement execution",
},
},
@ -118,6 +124,7 @@ func NewApp() *cli.App {
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
EnvVars: []string{"DBMATE_VERBOSE"},
Usage: "print the result of each statement execution",
},
},
@ -134,6 +141,7 @@ func NewApp() *cli.App {
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
EnvVars: []string{"DBMATE_VERBOSE"},
Usage: "print the result of each statement execution",
},
},