diff --git a/cmd/snippets.go b/cmd/snippets.go index 86f439c67..f69b232af 100644 --- a/cmd/snippets.go +++ b/cmd/snippets.go @@ -5,6 +5,7 @@ import ( "github.com/spf13/cobra" "github.com/supabase/cli/internal/snippets/download" "github.com/supabase/cli/internal/snippets/list" + "github.com/supabase/cli/internal/utils/flags" ) var ( @@ -35,6 +36,7 @@ var ( ) func init() { + snippetsCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.") snippetsCmd.AddCommand(snippetsListCmd) snippetsCmd.AddCommand(snippetsDownloadCmd) rootCmd.AddCommand(snippetsCmd) diff --git a/internal/snippets/list/list.go b/internal/snippets/list/list.go index 1bd47060f..f54325eaa 100644 --- a/internal/snippets/list/list.go +++ b/internal/snippets/list/list.go @@ -14,11 +14,8 @@ import ( ) func Run(ctx context.Context, fsys afero.Fs) error { - ref, err := flags.LoadProjectRef(fsys) - if err != nil { - return err - } - resp, err := utils.GetSupabase().V1ListAllSnippetsWithResponse(ctx, &api.V1ListAllSnippetsParams{ProjectRef: &ref}) + opts := api.V1ListAllSnippetsParams{ProjectRef: &flags.ProjectRef} + resp, err := utils.GetSupabase().V1ListAllSnippetsWithResponse(ctx, &opts) if err != nil { return errors.Errorf("failed to list snippets: %w", err) }