Skip to content

Commit

Permalink
add deprecation notices to cli cmds (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
notrab authored Jan 21, 2025
1 parent a136a64 commit 9751a45
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/cmd/db_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
"github.com/tursodatabase/turso-cli/internal/turso"
)

func showAttachDeprecationNotice() {
fmt.Println(internal.Warn("Notice: Database ATTACH is deprecated."))
fmt.Println(internal.Warn("For more information, visit: https://tur.so/attach-deprecated\n"))
}

func init() {
dbConfigCmd.AddCommand(dbAttachCmd)
dbAttachCmd.AddCommand(dbEnableAttachCmd)
Expand All @@ -27,6 +32,7 @@ var dbEnableAttachCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
ValidArgsFunction: dbNameArg,
RunE: func(cmd *cobra.Command, args []string) error {
showAttachDeprecationNotice()
cmd.SilenceUsage = true
return updateAttachStatus(args[0], true)
},
Expand All @@ -38,6 +44,7 @@ var dbDisableAttachCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
ValidArgsFunction: dbNameArg,
RunE: func(cmd *cobra.Command, args []string) error {
showAttachDeprecationNotice()
cmd.SilenceUsage = true
return updateAttachStatus(args[0], false)
},
Expand All @@ -49,6 +56,7 @@ var dbShowAttachStatusCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
ValidArgsFunction: dbNameArg,
RunE: func(cmd *cobra.Command, args []string) error {
showAttachDeprecationNotice()
cmd.SilenceUsage = true
client, err := authedTursoClient()
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions internal/cmd/db_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
"github.com/tursodatabase/turso-cli/internal/turso"
)

func showSchemaDeprecationNotice() {
fmt.Println(internal.Warn("Notice: Schema Databases are deprecated."))
fmt.Println(internal.Warn("For more information, visit: https://tur.so/schema-deprecated\n"))
}

const MaxDumpFileSizeBytes = 8 << 30

func init() {
Expand Down Expand Up @@ -39,6 +44,12 @@ var createCmd = &cobra.Command{
Short: "Create a database.",
Args: cobra.MaximumNArgs(1),
ValidArgsFunction: noFilesArg,
PreRunE: func(cmd *cobra.Command, args []string) error {
if schemaFlag != "" || typeFlag == "schema" {
showSchemaDeprecationNotice()
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true
name, err := getDatabaseName(args)
Expand Down
11 changes: 11 additions & 0 deletions internal/cmd/group_locations.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
"golang.org/x/exp/maps"
)

func showEdgeReplicaDeprecationNotice() {
fmt.Println(internal.Warn("Notice: Edge Replicas are deprecated."))
fmt.Println(internal.Warn("For more information, visit: https://tur.so/replicas-deprecated\n"))
}

var groupLocationsCmd = &cobra.Command{
Use: "locations",
Short: "Manage your database group locations",
Expand All @@ -29,6 +34,8 @@ var groupLocationsListCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
ValidArgsFunction: noFilesArg,
RunE: func(cmd *cobra.Command, args []string) error {
showEdgeReplicaDeprecationNotice()

group := args[0]
if group == "" {
return fmt.Errorf("the first argument must contain a group name")
Expand Down Expand Up @@ -56,6 +63,8 @@ var groupLocationAddCmd = &cobra.Command{
Args: cobra.MinimumNArgs(1),
ValidArgsFunction: locationsAddArgs,
RunE: func(cmd *cobra.Command, args []string) error {
showEdgeReplicaDeprecationNotice()

groupName := args[0]
if groupName == "" {
return fmt.Errorf("the first argument must contain a group name")
Expand Down Expand Up @@ -133,6 +142,8 @@ var groupsLocationsRmCmd = &cobra.Command{
Args: cobra.MinimumNArgs(2),
ValidArgsFunction: locationsRmArgs,
RunE: func(cmd *cobra.Command, args []string) error {
showEdgeReplicaDeprecationNotice()

groupName := args[0]
if groupName == "" {
return fmt.Errorf("the group flag is required")
Expand Down

0 comments on commit 9751a45

Please sign in to comment.