diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-04-06 13:51:17 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-04-08 15:45:01 +0300 |
commit | c757471f6445c104a65068f6d860fac65d3f11de (patch) | |
tree | c78ca563d7159f844dfb6f732f3399b26458f29e | |
parent | 1765378dd8bd921513e0dd73218d0f8c09b44f9d (diff) |
praefect: Use standard help format for `sql-migrate-down` subcommand
We currently hand-code the usage information of the `sql-migrate-down`
subcommand. This is inconsistent with how all the other commands print
their usage, so let's convert this to use `flag.PrintDefaults()`.
-rw-r--r-- | cmd/praefect/subcmd_sqldown.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/cmd/praefect/subcmd_sqldown.go b/cmd/praefect/subcmd_sqldown.go index 6e0d41275..2748de0d0 100644 --- a/cmd/praefect/subcmd_sqldown.go +++ b/cmd/praefect/subcmd_sqldown.go @@ -14,14 +14,12 @@ type sqlMigrateDownSubcommand struct { force bool } -func (*sqlMigrateDownSubcommand) prefix() string { return progname + " sql-migrate-down" } - -func (*sqlMigrateDownSubcommand) invocation() string { return invocationPrefix + " sql-migrate-down" } - func (s *sqlMigrateDownSubcommand) FlagSet() *flag.FlagSet { - flags := flag.NewFlagSet(s.prefix(), flag.ExitOnError) + flags := flag.NewFlagSet("sql-migrate-down", flag.ExitOnError) flags.Usage = func() { - printfErr("usage: %s [-f] MAX_MIGRATIONS\n", s.invocation()) + flag.PrintDefaults() + printfErr(" MAX_MIGRATIONS\n") + printfErr("\tNumber of migrations to roll back\n") } flags.BoolVar(&s.force, "f", false, "apply down-migrations (default is dry run)") return flags @@ -48,7 +46,7 @@ func (s *sqlMigrateDownSubcommand) Exec(flags *flag.FlagSet, conf config.Config) return err } - fmt.Printf("%s: OK (applied %d \"down\" migrations)\n", s.prefix(), n) + fmt.Printf("OK (applied %d \"down\" migrations)\n", n) return nil } @@ -57,11 +55,11 @@ func (s *sqlMigrateDownSubcommand) Exec(flags *flag.FlagSet, conf config.Config) return err } - fmt.Printf("%s: DRY RUN -- would roll back:\n\n", s.prefix()) + fmt.Printf("DRY RUN -- would roll back:\n\n") for _, id := range planned { fmt.Printf("- %s\n", id) } - fmt.Printf("\nTo apply these migrations run: %s -f %d\n", s.invocation(), maxMigrations) + fmt.Printf("\nTo apply these migrations run with -f\n") return nil } |