-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathsnippets.go
43 lines (38 loc) · 1.19 KB
/
snippets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cmd
import (
"github.com/spf13/afero"
"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 (
snippetsCmd = &cobra.Command{
GroupID: groupManagementAPI,
Use: "snippets",
Short: "Manage Supabase SQL snippets",
}
snippetsListCmd = &cobra.Command{
Use: "list",
Short: "List all SQL snippets",
Long: "List all SQL snippets of the linked project.",
RunE: func(cmd *cobra.Command, args []string) error {
return list.Run(cmd.Context(), afero.NewOsFs())
},
}
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),
RunE: func(cmd *cobra.Command, args []string) error {
return download.Run(cmd.Context(), args[0], afero.NewOsFs())
},
}
)
func init() {
snippetsCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
snippetsCmd.AddCommand(snippetsListCmd)
snippetsCmd.AddCommand(snippetsDownloadCmd)
rootCmd.AddCommand(snippetsCmd)
}