Skip to content

Commit 2ed4249

Browse files
committed
Move command outside status subgroup
1 parent 53adce9 commit 2ed4249

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

cli/users.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ func users() *cobra.Command {
1818
cmd.AddCommand(
1919
userCreate(),
2020
userList(),
21-
userStatus(),
21+
createUserStatusCommand(codersdk.UserStatusActive),
22+
createUserStatusCommand(codersdk.UserStatusSuspended),
2223
)
2324
return cmd
2425
}

cli/userstatus.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ import (
1010
"github.com/coder/coder/codersdk"
1111
)
1212

13-
func userStatus() *cobra.Command {
14-
cmd := &cobra.Command{
15-
Use: "status",
16-
Short: "Update the status of a user",
17-
}
18-
cmd.AddCommand(
19-
createUserStatusCommand(codersdk.UserStatusActive),
20-
createUserStatusCommand(codersdk.UserStatusSuspended),
21-
)
22-
return cmd
23-
}
24-
2513
// createUserStatusCommand sets a user status.
2614
func createUserStatusCommand(sdkStatus codersdk.UserStatus) *cobra.Command {
2715
var verb string
@@ -48,7 +36,7 @@ func createUserStatusCommand(sdkStatus codersdk.UserStatus) *cobra.Command {
4836
Short: short,
4937
Args: cobra.ExactArgs(1),
5038
Aliases: aliases,
51-
Example: fmt.Sprintf("coder users status %s example_user", verb),
39+
Example: fmt.Sprintf("coder users %s example_user", verb),
5240
RunE: func(cmd *cobra.Command, args []string) error {
5341
client, err := createClient(cmd)
5442
if err != nil {

cli/userstatus_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestUserStatus(t *testing.T) {
2222

2323
//nolint:paralleltest
2424
t.Run("StatusSelf", func(t *testing.T) {
25-
cmd, root := clitest.New(t, "users", "status", "suspend", "me")
25+
cmd, root := clitest.New(t, "users", "suspend", "me")
2626
clitest.SetupConfig(t, client, root)
2727
// Yes to the prompt
2828
cmd.SetIn(bytes.NewReader([]byte("yes\n")))
@@ -36,7 +36,7 @@ func TestUserStatus(t *testing.T) {
3636
t.Run("StatusOther", func(t *testing.T) {
3737
require.Equal(t, otherUser.Status, codersdk.UserStatusActive, "start as active")
3838

39-
cmd, root := clitest.New(t, "users", "status", "suspend", otherUser.Username)
39+
cmd, root := clitest.New(t, "users", "suspend", otherUser.Username)
4040
clitest.SetupConfig(t, client, root)
4141
// Yes to the prompt
4242
cmd.SetIn(bytes.NewReader([]byte("yes\n")))
@@ -48,8 +48,8 @@ func TestUserStatus(t *testing.T) {
4848
require.NoError(t, err, "fetch suspended user")
4949
require.Equal(t, otherUser.Status, codersdk.UserStatusSuspended, "suspended user")
5050

51-
// Set back to active
52-
cmd, root = clitest.New(t, "users", "status", "active", otherUser.Username)
51+
// Set back to active. Try using a uuid as well
52+
cmd, root = clitest.New(t, "users", "activate", otherUser.ID.String())
5353
clitest.SetupConfig(t, client, root)
5454
// Yes to the prompt
5555
cmd.SetIn(bytes.NewReader([]byte("yes\n")))

0 commit comments

Comments
 (0)