Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Fix the -set-default flag for context create. #3044

Merged
merged 3 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3044.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cli: Fix the -set-default flag on `waypoint context create`
```
14 changes: 11 additions & 3 deletions internal/cli/context_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW we don't need the Defaults to true in the doc string since the CLI adds this automatically:

brian@localghost:waypoint λ waypoint context create -help                                                                                                                                                                                                                                                             
Command Options:
...
...

  -set-default
      Set this context as the new default for the CLI. Defaults to true. The
      default is true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make a PR to fix this real quick

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ha, I was fixing the website docs. Looks like the CLI prints the default, but the website docs don't?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noooo! I see, that's weird. 🤔 Maybe we need to update our docs gen then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that the cli help text is more important than the website docs, so I support reverting this for now.

})
f.StringVar(&flag.StringVar{
Name: "server-addr",
Expand Down
2 changes: 1 addition & 1 deletion website/content/commands/context-create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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=<string>` - Address for the server.
- `-server-auth-token=<string>` - Authentication token to use to connect to the server.
- `-server-tls` - If true, will connect to the server over TLS.
Expand Down