From 428691caa4af15f8042f6a8c674fe99d1c8d473f Mon Sep 17 00:00:00 2001 From: 1vn Date: Tue, 13 Nov 2018 15:06:51 -0500 Subject: [PATCH] port to example --- examples/go-migrations/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/go-migrations/main.go b/examples/go-migrations/main.go index bb323afd1..28970af22 100644 --- a/examples/go-migrations/main.go +++ b/examples/go-migrations/main.go @@ -25,20 +25,21 @@ func main() { flags.Parse(os.Args[1:]) args := flags.Args() + if len(args) == 0 || args[0] == "-h" || args[0] == "--help" { + flags.Usage() + return + } - if len(args) > 1 && args[0] == "create" { + switch args[0] { + case "create": if err := goose.Run("create", nil, *dir, args[1:]...); err != nil { log.Fatalf("goose run: %v", err) } return - } - - // TODO clean up arg/flag parsing flow - if args[0] == "fix" { + case "fix": if err := goose.Run("fix", nil, *dir); err != nil { log.Fatalf("goose run: %v", err) } - return } if len(args) < 3 {