diff --git a/.changelog/3044.txt b/.changelog/3044.txt new file mode 100644 index 00000000000..8cdb51b1412 --- /dev/null +++ b/.changelog/3044.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: Fix the -set-default flag on `waypoint context create` +``` diff --git a/internal/cli/context_create.go b/internal/cli/context_create.go index 4cd8c8a7127..0ca048a9abb 100644 --- a/internal/cli/context_create.go +++ b/internal/cli/context_create.go @@ -43,6 +43,13 @@ func (c *ContextCreateCommand) Run(args []string) int { return 1 } + if c.flagSetDefault { + if err := c.contextStorage.SetDefault(name); err != nil { + c.ui.Output(clierrors.Humanize(err), terminal.WithErrorStyle()) + return 1 + } + } + c.ui.Output("Context %q created.", name, terminal.WithSuccessStyle()) return 0 } @@ -51,9 +58,10 @@ func (c *ContextCreateCommand) Flags() *flag.Sets { return c.flagSet(0, func(set *flag.Sets) { f := set.NewSet("Command Options") f.BoolVar(&flag.BoolVar{ - Name: "set-default", - Target: &c.flagSetDefault, - Usage: "Set this context as the new default for the CLI.", + Name: "set-default", + Target: &c.flagSetDefault, + Default: true, + Usage: "Set this context as the new default for the CLI. Defaults to true.", }) f.StringVar(&flag.StringVar{ Name: "server-addr", diff --git a/website/content/commands/context-create.mdx b/website/content/commands/context-create.mdx index bb088f15b3f..60145ffd933 100644 --- a/website/content/commands/context-create.mdx +++ b/website/content/commands/context-create.mdx @@ -28,7 +28,7 @@ Creates a new context. #### Command Options -- `-set-default` - Set this context as the new default for the CLI. +- `-set-default` - Set this context as the new default for the CLI. Defaults to true. - `-server-addr=` - Address for the server. - `-server-auth-token=` - Authentication token to use to connect to the server. - `-server-tls` - If true, will connect to the server over TLS.