Skip to content

Commit 98666fd

Browse files
committed
switch -> set
1 parent 0524fc9 commit 98666fd

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

cli/organization.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ func (r *RootCmd) switchOrganization() *clibase.Cmd {
3838
client := new(codersdk.Client)
3939

4040
cmd := &clibase.Cmd{
41-
Use: "switch <organization name | ID>",
42-
Short: "Switch the organization used by the cli. Pass an empty string to reset to the default organization.",
43-
Long: "Switch the organization used by the cli. Pass an empty string to reset to the default organization.\n" + formatExamples(
41+
Use: "set <organization name | ID>",
42+
Short: "set the organization used by the CLI. Pass an empty string to reset to the default organization.",
43+
Long: "set the organization used by the CLI. Pass an empty string to reset to the default organization.\n" + formatExamples(
4444
example{
4545
Description: "Remove the current organization and defer to the default.",
46-
Command: "coder organizations switch ''",
46+
Command: "coder organizations set ''",
4747
},
4848
example{
4949
Description: "Switch to a custom organization.",
50-
Command: "coder organizations switch my-org",
50+
Command: "coder organizations set my-org",
5151
},
5252
),
5353
Middleware: clibase.Chain(
@@ -118,7 +118,7 @@ func (r *RootCmd) switchOrganization() *clibase.Cmd {
118118
var sdkError *codersdk.Error
119119
if errors.As(err, &sdkError) {
120120
if sdkError.Helper == "" && sdkError.StatusCode() != 500 {
121-
sdkError.Helper = `If this error persists, try unsetting your org with 'coder organizations switch ""'`
121+
sdkError.Helper = `If this error persists, try unsetting your org with 'coder organizations set ""'`
122122
}
123123
return sdkError
124124
}
@@ -167,13 +167,15 @@ func promptUserSelectOrg(inv *clibase.Invocation, conf config.Root, orgs []coder
167167
defaultOrg = orgs[index].Name
168168
}
169169

170-
const deselectOption = "--Deselect--"
170+
// deselectOption is the option to delete the organization config file and defer
171+
// to default behavior.
172+
const deselectOption = "[Default]"
171173
if defaultOrg == "" {
172174
defaultOrg = deselectOption
173175
}
174176

175177
// Pull value from a prompt
176-
_, _ = fmt.Fprintln(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Wrap, "Select an organization below to switch the current cli context to:"))
178+
_, _ = fmt.Fprintln(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Wrap, "Select an organization below to set the current CLI context to:"))
177179
value, err := cliui.Select(inv, cliui.SelectOptions{
178180
Options: append([]string{deselectOption}, orgNames(orgs)...),
179181
Default: defaultOrg,

cli/organization_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestOrganizationSwitch(t *testing.T) {
6666
exp, err := client.OrganizationByName(ctx, codersdk.Me, "foo")
6767
require.NoError(t, err)
6868

69-
inv, root := clitest.New(t, "organizations", "switch", "foo")
69+
inv, root := clitest.New(t, "organizations", "set", "foo")
7070
clitest.SetupConfig(t, client, root)
7171
pty := ptytest.New(t).Attach(inv)
7272
errC := make(chan error)

cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ func CurrentOrganization(r *RootCmd, inv *clibase.Invocation, client *codersdk.C
733733
return org.IsDefault
734734
})
735735
if index < 0 {
736-
return codersdk.Organization{}, xerrors.Errorf("unable to determine current organization. Use 'coder organizations switch <org>' to select an organization to use")
736+
return codersdk.Organization{}, xerrors.Errorf("unable to determine current organization. Use 'coder set <org>' to select an organization to use")
737737
}
738738

739739
return orgs[index], nil

0 commit comments

Comments
 (0)