From 996a73a27144a625080326f7340a11f837bd94fe Mon Sep 17 00:00:00 2001 From: jlisthood <98786963+jlisthood@users.noreply.github.com> Date: Wed, 11 May 2022 23:25:21 -0700 Subject: [PATCH] Fix panic when calling cmd.Do subsequently (#1614) --- internal/cmd/cmd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 4c36e96b3e..f78b47a077 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -19,6 +19,10 @@ import ( "github.com/kyleconroy/sqlc/internal/tracer" ) +func init() { + uploadCmd.Flags().BoolP("dry-run", "", false, "dump upload request (default: false)") +} + // Do runs the command logic. func Do(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) int { rootCmd := &cobra.Command{Use: "sqlc", SilenceUsage: true} @@ -29,7 +33,6 @@ func Do(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) int rootCmd.AddCommand(genCmd) rootCmd.AddCommand(initCmd) rootCmd.AddCommand(versionCmd) - uploadCmd.Flags().BoolP("dry-run", "", false, "dump upload request (default: false)") rootCmd.AddCommand(uploadCmd) rootCmd.SetArgs(args)