Skip to content

Commit

Permalink
fix(completion): Fix dump/restore completions creating a job
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Oct 7, 2023
1 parent 8ac8652 commit 06c1540
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ the generated filename might look like "` + dump.HelpFilename() + `"`,
return cmd
}

var setupOptions = util.SetupOptions{Name: "dump"}

func validArgs(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}

setupOptions.DisableJob = true
err := preRun(cmd, args)
if err != nil {
return []string{"sql", "sql.gz", "dmp", "archive", "archive.gz"}, cobra.ShellCompDirectiveFilterFileExt
Expand Down Expand Up @@ -87,7 +90,7 @@ func preRun(cmd *cobra.Command, args []string) (err error) {
cmd.SilenceUsage = false
}

if err := util.DefaultSetup(cmd, &action.Global, util.SetupOptions{Name: "dump"}); err != nil {
if err := util.DefaultSetup(cmd, &action.Global, setupOptions); err != nil {
return err
}

Expand Down
6 changes: 5 additions & 1 deletion cmd/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ Supported Input Filetypes:
return cmd
}

var setupOptions = util.SetupOptions{Name: "restore"}

func validArgs(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}

setupOptions.DisableJob = true

err := preRun(cmd, args)
if err != nil {
return []string{"sql", "sql.gz", "dmp", "archive", "archive.gz"}, cobra.ShellCompDirectiveFilterFileExt
Expand All @@ -76,7 +80,7 @@ func preRun(cmd *cobra.Command, args []string) (err error) {
action.Filename = args[0]
}

if err := util.DefaultSetup(cmd, &action.Global, util.SetupOptions{Name: "restore"}); err != nil {
if err := util.DefaultSetup(cmd, &action.Global, setupOptions); err != nil {
return err
}

Expand Down

0 comments on commit 06c1540

Please sign in to comment.