From 9fbce90a79498c83ed48f1c3feba243669687dad Mon Sep 17 00:00:00 2001 From: Liam Staskawicz <lstask@gmail.com> Date: Mon, 24 Dec 2012 12:12:31 -0800 Subject: [PATCH] flags: improved option names --- README.md | 8 ++++---- dbconf.go | 16 ++++++++-------- migrate.go | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8307f91..4069a79 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ goose expects you to maintain a folder (typically called "db"), which contains t * a dbconf.yml file that describes the database configurations you'd like to use * a folder called "migrations" which contains .sql and/or .go scripts that implement your migrations -You may use the `--db` option to specify an alternate location for the folder containing your config and migrations. +You may use the `-path` option to specify an alternate location for the folder containing your config and migrations. # Migrations @@ -65,7 +65,7 @@ A sample Go migration looks like: A transaction is provided, rather than the DB instance directly, since goose also needs to record the schema version within the same transaction. Each migration should run as a single transaction to ensure DB integrity, so it's good practice anyway. -## Database Configurations +## Database Environments A sample dbconf.yml looks like @@ -73,6 +73,6 @@ A sample dbconf.yml looks like driver: postgres open: user=liam dbname=tester sslmode=disable -Here, `development` specifies the name of the configuration, and the `driver` and `open` elements are passed directly to database/sql to access the specified database. +Here, `development` specifies the name of the environment, and the `driver` and `open` elements are passed directly to database/sql to access the specified database. -You may include as many configurations as you like, and you can use the `--config` command line option to specify which one to use. goose defaults to using a configuration called `development`. +You may include as many configurations as you like, and you can use the `-env` command line option to specify which one to use. goose defaults to using a configuration called `development`. diff --git a/dbconf.go b/dbconf.go index 32eb988..1e5f8ee 100644 --- a/dbconf.go +++ b/dbconf.go @@ -8,12 +8,12 @@ import ( ) // global options. available to any subcommands. -var dbFolder = flag.String("db", "db", "folder containing db info") -var dbConfName = flag.String("config", "development", "which DB configuration to use") +var dbPath = flag.String("path", "db", "folder containing db info") +var dbEnv = flag.String("env", "development", "which DB environment to use") type DBConf struct { MigrationsDir string - Name string + Env string Driver string OpenStr string } @@ -21,26 +21,26 @@ type DBConf struct { // extract configuration details from the given file func MakeDBConf() (*DBConf, error) { - cfgFile := path.Join(*dbFolder, "dbconf.yml") + cfgFile := path.Join(*dbPath, "dbconf.yml") f, err := yaml.ReadFile(cfgFile) if err != nil { return nil, err } - drv, derr := f.Get(fmt.Sprintf("%s.driver", *dbConfName)) + drv, derr := f.Get(fmt.Sprintf("%s.driver", *dbEnv)) if derr != nil { return nil, derr } - open, oerr := f.Get(fmt.Sprintf("%s.open", *dbConfName)) + open, oerr := f.Get(fmt.Sprintf("%s.open", *dbEnv)) if oerr != nil { return nil, oerr } return &DBConf{ - MigrationsDir: path.Join(*dbFolder, "migrations"), - Name: *dbConfName, + MigrationsDir: path.Join(*dbPath, "migrations"), + Env: *dbEnv, Driver: drv, OpenStr: open, }, nil diff --git a/migrate.go b/migrate.go index 7c3e188..e32703d 100644 --- a/migrate.go +++ b/migrate.go @@ -55,8 +55,8 @@ func runMigrations(conf *DBConf, migrationsDir string, target int) { return } - fmt.Printf("goose: migrating db configuration '%v', current version: %d, target: %d\n", - conf.Name, current, target) + fmt.Printf("goose: migrating db environment '%v', current version: %d, target: %d\n", + conf.Env, current, target) for _, v := range mm.Versions {