Skip to content

Commit

Permalink
fix: optional project ref flag for snippets command
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Dec 7, 2024
1 parent 9324c89 commit 6f87ea3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cmd/snippets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions internal/snippets/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6f87ea3

Please sign in to comment.