• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 3572813994

04 Dec 2022 06:36PM UTC coverage: 54.923% (-2.8%) from 57.76%
3572813994

Pull #648

github

Kevin Saliou
chore: remove all tabs & trailing spaces from SQL files
Pull Request #648: chore: remove all tabs & trailing spaces from SQL files

3057 of 5566 relevant lines covered (54.92%)

498.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.0
/cmd/link.go
1
package cmd
2

3
import (
4
        "fmt"
5
        "os"
6
        "os/signal"
7

8
        "github.com/spf13/afero"
9
        "github.com/spf13/cobra"
10
        "github.com/spf13/viper"
11
        "github.com/supabase/cli/internal/link"
12
        "github.com/supabase/cli/internal/utils"
13
        "golang.org/x/term"
14
)
15

16
var (
17
        // TODO: allow switching roles on backend
18
        database = "postgres"
19
        username = "postgres"
20

21
        linkCmd = &cobra.Command{
22
                GroupID: groupLocalDev,
23
                Use:     "link",
24
                Short:   "Link to a Supabase project",
25
                RunE: func(cmd *cobra.Command, args []string) error {
×
26
                        projectRef, err := cmd.Flags().GetString("project-ref")
×
27
                        if err != nil {
×
28
                                return err
×
29
                        }
×
30

31
                        password := viper.GetString("DB_PASSWORD")
×
32
                        if password == "" {
×
33
                                password = PromptPassword(os.Stdin)
×
34
                        }
×
35

36
                        fsys := afero.NewOsFs()
×
37
                        ctx, _ := signal.NotifyContext(cmd.Context(), os.Interrupt)
×
38
                        if err := link.Run(ctx, projectRef, username, password, database, fsys); err != nil {
×
39
                                return err
×
40
                        }
×
41

42
                        fmt.Println("Finished " + utils.Aqua("supabase link") + ".")
×
43
                        return nil
×
44
                },
45
        }
46
)
47

48
func init() {
34✔
49
        flags := linkCmd.Flags()
34✔
50
        flags.String("project-ref", "", "Project ref of the Supabase project.")
34✔
51
        flags.StringVarP(&dbPassword, "password", "p", "", "Password to your remote Postgres database.")
34✔
52
        cobra.CheckErr(viper.BindPFlag("DB_PASSWORD", flags.Lookup("password")))
34✔
53
        cobra.CheckErr(linkCmd.MarkFlagRequired("project-ref"))
34✔
54
        rootCmd.AddCommand(linkCmd)
34✔
55
}
34✔
56

57
func PromptPassword(stdin *os.File) string {
×
58
        fmt.Print("Enter your database password: ")
×
59
        bytepw, err := term.ReadPassword(int(stdin.Fd()))
×
60
        fmt.Println()
×
61
        if err != nil {
×
62
                return ""
×
63
        }
×
64
        return string(bytepw)
×
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc