From f1a780acbeaeb31a044b7c6db5d0f99ef8ed18a0 Mon Sep 17 00:00:00 2001 From: Jesse Liston Date: Wed, 11 May 2022 11:55:53 -0700 Subject: [PATCH] Fix panic when calling cmd.Do subsequently --- 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)