Skip to content

Commit b4182f8

Browse files
author
Athos
authored
Allow specifying vector version when creating groups (#869)
Also add vector groups to the CLI completion script
1 parent c2b5915 commit b4182f8

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

internal/cmd/canary_flag.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ var canaryFlag bool
66

77
func addCanaryFlag(cmd *cobra.Command) {
88
cmd.Flags().BoolVar(&canaryFlag, "canary", false, "Use database canary build.")
9+
_ = cmd.Flags().MarkHidden("canary")
910
}

internal/cmd/group.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/spf13/cobra"
88
"github.com/tursodatabase/turso-cli/internal"
9+
"github.com/tursodatabase/turso-cli/internal/flags"
910
"github.com/tursodatabase/turso-cli/internal/prompt"
1011
"github.com/tursodatabase/turso-cli/internal/turso"
1112
)
@@ -23,6 +24,7 @@ func init() {
2324
addLocationFlag(groupsCreateCmd, "Create the group primary in the specified location")
2425
addWaitFlag(groupsCreateCmd, "Wait for group to be ready")
2526
addCanaryFlag(groupsCreateCmd)
27+
flags.AddVersion(groupsCreateCmd, "Version of the group. Valid values: 'latest', 'canary' or 'vector'")
2628
groupCmd.AddCommand(groupsDestroyCmd)
2729
addYesFlag(groupsDestroyCmd, "Confirms the destruction of the group, with all its locations and databases.")
2830
groupCmd.AddCommand(groupShowCmd)
@@ -94,8 +96,11 @@ var groupsCreateCmd = &cobra.Command{
9496
return fmt.Errorf("location '%s' is not a valid one", location)
9597
}
9698

97-
version := "latest"
99+
version := flags.Version()
98100
if canaryFlag {
101+
if version != "" {
102+
return fmt.Errorf("cannot specify both --canary and --version flags")
103+
}
99104
version = "canary"
100105
}
101106

internal/cmd/group_update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func init() {
1414
groupCmd.AddCommand(groupUpdateCmd)
1515
flags.AddYes(groupUpdateCmd, "Confirms the update")
16-
flags.AddVersion(groupUpdateCmd, "Version to update to. Valid values: 'latest' or 'canary'")
16+
flags.AddVersion(groupUpdateCmd, "Version to update to. Valid values: 'latest', 'canary' or 'vector'")
1717
flags.AddExtensions(groupUpdateCmd, "Extensions to enable. Valid values: 'all' or 'none'")
1818
}
1919

internal/flags/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var versionFlag string
99
func AddVersion(cmd *cobra.Command, desc string) {
1010
cmd.Flags().StringVar(&versionFlag, "version", "", desc)
1111
_ = cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
12-
return []string{"latest", "canary"}, cobra.ShellCompDirectiveNoFileComp
12+
return []string{"latest", "canary", "vector"}, cobra.ShellCompDirectiveNoFileComp
1313
})
1414
}
1515

0 commit comments

Comments
 (0)