blob: c26afca22be5b2700be6a8f9005c9da728a080a5 [file] [log] [blame]
package main
import (
"fmt"
"os"
"github.com/mitchellh/cli"
)
func main() {
os.Exit(realMain())
}
var ui cli.Ui
func realMain() int {
ui = &cli.BasicUi{Writer: os.Stdout}
cli := &cli.CLI{
Args: os.Args[1:],
Commands: map[string]cli.CommandFactory{
"up": func() (cli.Command, error) {
return &UpCommand{}, nil
},
"down": func() (cli.Command, error) {
return &DownCommand{}, nil
},
"redo": func() (cli.Command, error) {
return &RedoCommand{}, nil
},
"status": func() (cli.Command, error) {
return &StatusCommand{}, nil
},
},
HelpFunc: cli.BasicHelpFunc("sql-migrate"),
Version: "1.0.0",
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1
}
return exitCode
}