Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 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/snippets/push"
"github.com/supabase/cli/internal/utils/flags"
)

Expand All @@ -25,19 +26,33 @@ var (
}

snippetsDownloadCmd = &cobra.Command{
Use: "download <snippet-id>",
Short: "Download contents of a SQL snippet",
Long: "Download contents of the specified SQL snippet.",
Args: cobra.ExactArgs(1),
Use: "download [snippet-id]",
Short: "Download one or all SQL snippets",
Long: "Download the contents of the specified SQL snippet if an ID is provided. If no ID is supplied, download all snippets into the local project directory.",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return download.Run(cmd.Context(), args[0], afero.NewOsFs())
var snippetId string
if len(args) > 0 {
snippetId = args[0]
}
return download.Run(cmd.Context(), snippetId, afero.NewOsFs())
},
}

snippetsPushCmd = &cobra.Command{
Use: "push",
Short: "Push local SQL snippets to Supabase",
Long: "Create or update SQL snippets from the local supabase/snippets directory to the linked project.",
RunE: func(cmd *cobra.Command, args []string) error {
return push.Run(cmd.Context(), afero.NewOsFs())
},
}
)

func init() {
snippetsCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
snippetsCmd.AddCommand(snippetsListCmd)
snippetsCmd.AddCommand(snippetsDownloadCmd)
snippetsCmd.AddCommand(snippetsPushCmd)
rootCmd.AddCommand(snippetsCmd)
}
43 changes: 43 additions & 0 deletions cmd/tests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package cmd

import (
"github.com/spf13/afero"
"github.com/spf13/cobra"
testsDownload "github.com/supabase/cli/internal/tests/download"
testsPush "github.com/supabase/cli/internal/tests/push"
"github.com/supabase/cli/internal/utils/flags"
)

var (
testsCmd = &cobra.Command{
GroupID: groupManagementAPI,
Use: "tests",
Short: "Manage Supabase SQL tests",
}

testsDownloadCmd = &cobra.Command{
Use: "download [test-id]",
Short: "Download one or all SQL tests",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var id string
if len(args) > 0 { id = args[0] }
return testsDownload.Run(cmd.Context(), id, afero.NewOsFs())
},
}

testsPushCmd = &cobra.Command{
Use: "push",
Short: "Push local SQL tests to Supabase",
RunE: func(cmd *cobra.Command, args []string) error {
return testsPush.Run(cmd.Context(), afero.NewOsFs())
},
}
)

func init() {
testsCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
testsCmd.AddCommand(testsDownloadCmd)
testsCmd.AddCommand(testsPushCmd)
rootCmd.AddCommand(testsCmd)
}
Loading
Loading