Skip to content

Commit

Permalink
🎨 Add missing flag shorthands
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 24, 2021
1 parent 305057b commit 81341e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var Command = &cobra.Command{
Use: "dump",
Aliases: []string{"d"},
Short: "Dump a database",
PreRunE: validate,
PreRunE: preRun,
RunE: run,
}

Expand Down Expand Up @@ -52,11 +52,11 @@ func init() {
Command.Flags().StringP("format", "F", "g", "output file format ([g]zip, [c]ustom, [p]lain text)")

Command.Flags().BoolVar(&ifExists, "if-exists", true, "use IF EXISTS when dropping objects")
Command.Flags().BoolVar(&clean, "clean", true, "clean (drop) database objects before recreating")
Command.Flags().BoolVar(&noOwner, "no-owner", true, "skip restoration of object ownership in plain-text format")
Command.Flags().BoolVarP(&clean, "clean", "c", true, "clean (drop) database objects before recreating")
Command.Flags().BoolVarP(&noOwner, "no-owner", "O", true, "skip restoration of object ownership in plain-text format")
}

func validate(cmd *cobra.Command, args []string) (err error) {
func preRun(cmd *cobra.Command, args []string) error {
format, _ := cmd.Flags().GetString("format")
switch format {
case "gzip", "gz", "g":
Expand All @@ -68,7 +68,7 @@ func validate(cmd *cobra.Command, args []string) (err error) {
default:
return errors.New("invalid output format specified")
}
return err
return nil
}

func run(cmd *cobra.Command, args []string) (err error) {
Expand Down

0 comments on commit 81341e2

Please sign in to comment.