Skip to content

Commit 8a86eb0

Browse files
committed
add shorthand
1 parent fcf27d3 commit 8a86eb0

File tree

2 files changed

+36
-46
lines changed

2 files changed

+36
-46
lines changed

cli/organization_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestCurrentOrganization(t *testing.T) {
4343
defer srv.Close()
4444

4545
client := codersdk.New(must(url.Parse(srv.URL)))
46-
inv, root := clitest.New(t, "organizations", "show", "current")
46+
inv, root := clitest.New(t, "organizations", "show", "selected")
4747
clitest.SetupConfig(t, client, root)
4848
pty := ptytest.New(t).Attach(inv)
4949
errC := make(chan error)
@@ -70,7 +70,7 @@ func TestCurrentOrganization(t *testing.T) {
7070
require.NoError(t, err)
7171
}
7272

73-
inv, root := clitest.New(t, "organizations", "show", "--only-id")
73+
inv, root := clitest.New(t, "organizations", "show", "--only-id", "--org="+first.OrganizationID.String())
7474
clitest.SetupConfig(t, client, root)
7575
pty := ptytest.New(t).Attach(inv)
7676
errC := make(chan error)
@@ -101,7 +101,7 @@ func TestCurrentOrganization(t *testing.T) {
101101
orgs[orgName] = org
102102
}
103103

104-
inv, root := clitest.New(t, "organizations", "show", "current", "--only-id", "-z=bar")
104+
inv, root := clitest.New(t, "organizations", "show", "selected", "--only-id", "-z=bar")
105105
clitest.SetupConfig(t, client, root)
106106
pty := ptytest.New(t).Attach(inv)
107107
errC := make(chan error)

cli/root.go

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,19 @@ var (
5353
)
5454

5555
const (
56-
varURL = "url"
57-
varToken = "token"
58-
varAgentToken = "agent-token"
59-
varAgentTokenFile = "agent-token-file"
60-
varAgentURL = "agent-url"
61-
varHeader = "header"
62-
varHeaderCommand = "header-command"
63-
varNoOpen = "no-open"
64-
varNoVersionCheck = "no-version-warning"
65-
varNoFeatureWarning = "no-feature-warning"
66-
varForceTty = "force-tty"
67-
varVerbose = "verbose"
68-
varOrganizationSelect = "organization"
69-
varDisableDirect = "disable-direct-connections"
56+
varURL = "url"
57+
varToken = "token"
58+
varAgentToken = "agent-token"
59+
varAgentTokenFile = "agent-token-file"
60+
varAgentURL = "agent-url"
61+
varHeader = "header"
62+
varHeaderCommand = "header-command"
63+
varNoOpen = "no-open"
64+
varNoVersionCheck = "no-version-warning"
65+
varNoFeatureWarning = "no-feature-warning"
66+
varForceTty = "force-tty"
67+
varVerbose = "verbose"
68+
varDisableDirect = "disable-direct-connections"
7069

7170
notLoggedInMessage = "You are not logged in. Try logging in using 'coder login <url>'."
7271

@@ -452,15 +451,6 @@ func (r *RootCmd) Command(subcommands []*serpent.Command) (*serpent.Command, err
452451
Value: serpent.StringOf(&r.globalConfig),
453452
Group: globalGroup,
454453
},
455-
{
456-
Flag: varOrganizationSelect,
457-
FlagShorthand: "z",
458-
Env: "CODER_ORGANIZATION",
459-
Description: "Select which organization (uuid or name) to use This overrides what is present in the config file.",
460-
Value: serpent.StringOf(&r.organizationSelect),
461-
Hidden: true,
462-
Group: globalGroup,
463-
},
464454
{
465455
Flag: "version",
466456
// This was requested by a customer to assist with their migration.
@@ -477,21 +467,20 @@ func (r *RootCmd) Command(subcommands []*serpent.Command) (*serpent.Command, err
477467

478468
// RootCmd contains parameters and helpers useful to all commands.
479469
type RootCmd struct {
480-
clientURL *url.URL
481-
token string
482-
globalConfig string
483-
header []string
484-
headerCommand string
485-
agentToken string
486-
agentTokenFile string
487-
agentURL *url.URL
488-
forceTTY bool
489-
noOpen bool
490-
verbose bool
491-
organizationSelect string
492-
versionFlag bool
493-
disableDirect bool
494-
debugHTTP bool
470+
clientURL *url.URL
471+
token string
472+
globalConfig string
473+
header []string
474+
headerCommand string
475+
agentToken string
476+
agentTokenFile string
477+
agentURL *url.URL
478+
forceTTY bool
479+
noOpen bool
480+
verbose bool
481+
versionFlag bool
482+
disableDirect bool
483+
debugHTTP bool
495484

496485
noVersionCheck bool
497486
noFeatureWarning bool
@@ -645,13 +634,14 @@ func NewOrganizationContext() *OrganizationContext {
645634
func (o *OrganizationContext) AttachOptions(cmd *serpent.Command) {
646635
cmd.Options = append(cmd.Options, serpent.Option{
647636
Name: "Organization",
648-
Description: "Set the organization for the command to use.",
637+
Description: "Select which organization (uuid or name) to use.",
649638
// Only required if the user is a part of more than 1 organization.
650639
// Otherwise, we can assume a default value.
651-
Required: false,
652-
Flag: "org",
653-
Env: "CODER_ORGANIZATION",
654-
Value: serpent.StringOf(&o.FlagSelect),
640+
Required: false,
641+
Flag: "org",
642+
FlagShorthand: "z",
643+
Env: "CODER_ORGANIZATION",
644+
Value: serpent.StringOf(&o.FlagSelect),
655645
})
656646
}
657647

0 commit comments

Comments
 (0)