Skip to content

Commit 649779d

Browse files
committed
Fixed an Error with Supbase
1 parent 9638c94 commit 649779d

1 file changed

Lines changed: 2 additions & 29 deletions

File tree

cmd/root.go

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ var (
1616
// Global configuration
1717
cfg *config.Config
1818

19-
// Supabase configuration flags
20-
supabaseURL string
21-
supabaseAPIKey string
22-
2319
// Supabase client
2420
supabaseClient *supabase.Client
2521

@@ -35,22 +31,6 @@ func init() {
3531
// Initialize config
3632
cfg = config.New()
3733

38-
// Add persistent flags for Supabase
39-
rootCmd.PersistentFlags().StringVarP(&supabaseURL, "supabase-url", "u", cfg.SupabaseURL, "Supabase project URL")
40-
rootCmd.PersistentFlags().StringVarP(&supabaseAPIKey, "supabase-key", "k", cfg.SupabaseAPIKey, "Supabase API key")
41-
42-
// Bind flags to config
43-
if err := cfg.BindFlags(pflag.CommandLine); err != nil {
44-
log.Fatalf("Failed to bind flags: %v", err)
45-
}
46-
47-
// Initialize Supabase client
48-
var err error
49-
supabaseClient, err = initSupabase()
50-
if err != nil {
51-
log.Fatalf("Failed to initialize Supabase client: %v", err)
52-
}
53-
5434
// Add commands directly to root
5535
rootCmd.AddCommand(versionCmd)
5636
rootCmd.AddCommand(loginCmd)
@@ -87,7 +67,7 @@ func init() {
8767

8868
// Initialize Supabase client
8969
var err error
90-
supabaseClient, err = initSupabase()
70+
supabaseClient, err = initSupabase(cfg.SupabaseURL, cfg.SupabaseAPIKey)
9171
if err != nil {
9272
return fmt.Errorf("failed to initialize Supabase client: %w", err)
9373
}
@@ -110,7 +90,7 @@ func init() {
11090
}
11191

11292
// initSupabase initializes the Supabase client with the current configuration
113-
func initSupabase() (*supabase.Client, error) {
93+
func initSupabase(supabaseURL, supabaseAPIKey string) (*supabase.Client, error) {
11494
if supabaseURL == "" || supabaseAPIKey == "" {
11595
return nil, fmt.Errorf("supabase URL and API key must be set")
11696
}
@@ -139,13 +119,6 @@ func requireAuth(cmd *cobra.Command, args []string) error {
139119

140120
// Execute runs the root command
141121
func Execute() {
142-
// Initialize Supabase client
143-
var err error
144-
supabaseClient, err = initSupabase()
145-
if err != nil {
146-
log.Printf("Warning: Failed to initialize Supabase client: %v", err)
147-
}
148-
149122
// Execute the command
150123
if err := rootCmd.Execute(); err != nil {
151124
log.Printf("Error: %v", err)

0 commit comments

Comments
 (0)