From db0799b7b31567d48df004569fb1db2ea51dc29c Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Tue, 26 Oct 2021 20:48:32 +0800 Subject: [PATCH] fix(link): take url as string arg --- cmd/link.go | 20 ++++---------------- examples/tour/README.md | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/cmd/link.go b/cmd/link.go index 00d8a648a..9ecaaf79d 100644 --- a/cmd/link.go +++ b/cmd/link.go @@ -1,38 +1,26 @@ package cmd import ( - "errors" - "fmt" - "github.com/spf13/cobra" "github.com/supabase/cli/internal/link" ) var ( - useUrl bool + deployDbUrl string linkCmd = &cobra.Command{ Use: "link", Short: "Link the current project to a remote deploy database.", RunE: func(cmd *cobra.Command, args []string) error { - if useUrl { - var deployDbUrl string - fmt.Scanln(&deployDbUrl) - if len(deployDbUrl) == 0 { - return errors.New("Error on `supabase link`: URL is empty.") - } - - return link.Link(deployDbUrl) - } - - return errors.New("Use `--url` to pass the deploy database URL to link to.") + return link.Link(deployDbUrl) }, } ) func init() { linkCmd.Flags(). - BoolVar(&useUrl, "url", false, "Accept Postgres connection string of the deploy database from standard input.") + StringVar(&deployDbUrl, "url", "", "Postgres connection string of the deploy database.") + cobra.CheckErr(linkCmd.MarkFlagRequired("url")) rootCmd.AddCommand(linkCmd) } diff --git a/examples/tour/README.md b/examples/tour/README.md index 9e8c8e3b8..a094cfd2a 100644 --- a/examples/tour/README.md +++ b/examples/tour/README.md @@ -25,7 +25,7 @@ supabase init This will create a `supabase` directory which is managed by the CLI. Then we need to link the current project with the deploy database. Use the connection string from your Supabase project here. ```sh -supabase link --url <<< 'postgresql://postgres:@db..supabase.co:5432/postgres' +supabase link --url 'postgresql://postgres:@db..supabase.co:5432/postgres' ``` Why do we need to do this? Because if we want to manage a database with a migration tool, we need a _baseline_ where both the migration tool and the database have consistent schemas. `supabase link` does this synchronization between the two.