Skip to content

Commit

Permalink
Add supbase studio command
Browse files Browse the repository at this point in the history
  • Loading branch information
jsj committed Dec 4, 2024
1 parent 06db5a5 commit 6468312
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions cmd/studio.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cmd

import (
"fmt"
"os/exec"
"runtime"

"github.com/spf13/cobra"
"github.com/supabase/cli/internal/utils"
)

var studioCmd = &cobra.Command{
Use: "studio",
Short: "Opens Supabase Studio in your browser",
RunE: func(cmd *cobra.Command, args []string) error {
url := utils.GetSupabaseDashboardURL()
var err error

switch runtime.GOOS {
case "darwin":
err = exec.Command("open", url).Start()
case "windows":
err = exec.Command("cmd", "/c", "start", url).Start()
default:
err = exec.Command("xdg-open", url).Start()
}

if err != nil {
return fmt.Errorf("failed to open browser: %w", err)
}

fmt.Printf("Opening Supabase Studio at %s\n", utils.Aqua(url))
return nil
},
}

func init() {
rootCmd.AddCommand(studioCmd)
}

0 comments on commit 6468312

Please sign in to comment.