Make command name more specific and consistent output formatting

pull/2/head
Luke Hutton 2014-03-14 14:00:22 -07:00
parent 09600ab4d7
commit fff1cda8bd
4 changed files with 33 additions and 33 deletions

View File

@ -74,12 +74,12 @@ Print the status of all migrations:
$ Sun Jan 6 11:25:03 2013 -- 002_next.sql
$ Pending -- 003_and_again.go
## version
## dbversion
Print the current version of the database:
$ goose version
$ 002
$ goose dbversion
$ goose: dbversion 002
`goose -h` provides more detailed info on each command.

View File

@ -0,0 +1,29 @@
package main
import (
"bitbucket.org/liamstask/goose/lib/goose"
"fmt"
"log"
)
var dbVersionCmd = &Command{
Name: "dbversion",
Usage: "",
Summary: "Print the current version of the database",
Help: `dbversion extended help here...`,
Run: dbVersionRun,
}
func dbVersionRun(cmd *Command, args ...string) {
conf, err := dbConfFromFlags()
if err != nil {
log.Fatal(err)
}
current, err := goose.GetDBVersion(conf)
if err != nil {
log.Fatal(err)
}
fmt.Printf("goose: dbversion %v\n", current)
}

View File

@ -1,29 +0,0 @@
package main
import (
"bitbucket.org/liamstask/goose/lib/goose"
"fmt"
"log"
)
var versionCmd = &Command{
Name: "version",
Usage: "",
Summary: "Retrieve the current version for the DB",
Help: `version extended help here...`,
Run: versionRun,
}
func versionRun(cmd *Command, args ...string) {
conf, err := dbConfFromFlags()
if err != nil {
log.Fatal(err)
}
current, err := goose.GetDBVersion(conf)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v\n", current)
}

View File

@ -24,7 +24,7 @@ var commands = []*Command{
redoCmd,
statusCmd,
createCmd,
versionCmd,
dbVersionCmd,
}
func main() {