-
-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
5 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters