From 63ea39a74c29381661324943b976f7c6911a3167 Mon Sep 17 00:00:00 2001 From: kylecarbs Date: Sun, 1 May 2022 16:13:15 +0000 Subject: [PATCH] fix: Unnest workspaces command to the top-level This changes all "coder workspace *" commands to root. A few of these were already at the root, like SSH. The inconsistency made for a confusing experience. --- cli/{workspaceautostart.go => autostart.go} | 22 ++++---- ...aceautostart_test.go => autostart_test.go} | 12 ++--- cli/{workspaceautostop.go => autostop.go} | 22 ++++---- ...spaceautostop_test.go => autostop_test.go} | 12 ++--- cli/cliui/agent.go | 2 +- cli/{workspacecreate.go => create.go} | 2 +- ...workspacecreate_test.go => create_test.go} | 10 ++-- cli/{workspacedelete.go => delete.go} | 10 ++-- cli/{workspacelist.go => list.go} | 4 +- cli/root.go | 20 +++++--- cli/{workspaceshow.go => show.go} | 2 +- cli/{workspacestart.go => start.go} | 7 ++- cli/{workspacestop.go => stop.go} | 7 ++- cli/templatecreate.go | 2 +- cli/tunnel.go | 2 +- cli/{workspaceupdate.go => update.go} | 2 +- cli/usercreate.go | 2 +- cli/workspaces.go | 51 ------------------- docs/README.md | 2 +- docs/workspaces.md | 6 +-- 20 files changed, 75 insertions(+), 124 deletions(-) rename cli/{workspaceautostart.go => autostart.go} (82%) rename cli/{workspaceautostart_test.go => autostart_test.go} (88%) rename cli/{workspaceautostop.go => autostop.go} (82%) rename cli/{workspaceautostop_test.go => autostop_test.go} (88%) rename cli/{workspacecreate.go => create.go} (99%) rename cli/{workspacecreate_test.go => create_test.go} (93%) rename cli/{workspacedelete.go => delete.go} (81%) rename cli/{workspacelist.go => list.go} (96%) rename cli/{workspaceshow.go => show.go} (96%) rename cli/{workspacestart.go => start.go} (88%) rename cli/{workspacestop.go => stop.go} (89%) rename cli/{workspaceupdate.go => update.go} (96%) delete mode 100644 cli/workspaces.go diff --git a/cli/workspaceautostart.go b/cli/autostart.go similarity index 82% rename from cli/workspaceautostart.go rename to cli/autostart.go index 857893eb6e5ce..fed05689e2c5b 100644 --- a/cli/workspaceautostart.go +++ b/cli/autostart.go @@ -16,31 +16,30 @@ When enabling autostart, provide the minute, hour, and day(s) of week. The default schedule is at 09:00 in your local timezone (TZ env, UTC by default). ` -func workspaceAutostart() *cobra.Command { +func autostart() *cobra.Command { autostartCmd := &cobra.Command{ Use: "autostart enable ", Short: "schedule a workspace to automatically start at a regular time", Long: autostartDescriptionLong, - Example: "coder workspaces autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin", + Example: "coder autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin", Hidden: true, } - autostartCmd.AddCommand(workspaceAutostartEnable()) - autostartCmd.AddCommand(workspaceAutostartDisable()) + autostartCmd.AddCommand(autostartEnable()) + autostartCmd.AddCommand(autostartDisable()) return autostartCmd } -func workspaceAutostartEnable() *cobra.Command { +func autostartEnable() *cobra.Command { // yes some of these are technically numbers but the cron library will do that work var autostartMinute string var autostartHour string var autostartDayOfWeek string var autostartTimezone string cmd := &cobra.Command{ - Use: "enable ", - ValidArgsFunction: validArgsWorkspaceName, - Args: cobra.ExactArgs(1), + Use: "enable ", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { client, err := createClient(cmd) if err != nil { @@ -86,11 +85,10 @@ func workspaceAutostartEnable() *cobra.Command { return cmd } -func workspaceAutostartDisable() *cobra.Command { +func autostartDisable() *cobra.Command { return &cobra.Command{ - Use: "disable ", - ValidArgsFunction: validArgsWorkspaceName, - Args: cobra.ExactArgs(1), + Use: "disable ", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { client, err := createClient(cmd) if err != nil { diff --git a/cli/workspaceautostart_test.go b/cli/autostart_test.go similarity index 88% rename from cli/workspaceautostart_test.go rename to cli/autostart_test.go index 196864e394e70..4ef725e516f0a 100644 --- a/cli/workspaceautostart_test.go +++ b/cli/autostart_test.go @@ -13,7 +13,7 @@ import ( "github.com/coder/coder/coderd/coderdtest" ) -func TestWorkspaceAutostart(t *testing.T) { +func TestAutostart(t *testing.T) { t.Parallel() t.Run("EnableDisableOK", func(t *testing.T) { @@ -29,7 +29,7 @@ func TestWorkspaceAutostart(t *testing.T) { project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID) tz = "Europe/Dublin" - cmdArgs = []string{"workspaces", "autostart", "enable", workspace.Name, "--minute", "30", "--hour", "9", "--days", "1-5", "--tz", tz} + cmdArgs = []string{"autostart", "enable", workspace.Name, "--minute", "30", "--hour", "9", "--days", "1-5", "--tz", tz} sched = "CRON_TZ=Europe/Dublin 30 9 * * 1-5" stdoutBuf = &bytes.Buffer{} ) @@ -48,7 +48,7 @@ func TestWorkspaceAutostart(t *testing.T) { require.Equal(t, sched, updated.AutostartSchedule, "expected autostart schedule to be set") // Disable schedule - cmd, root = clitest.New(t, "workspaces", "autostart", "disable", workspace.Name) + cmd, root = clitest.New(t, "autostart", "disable", workspace.Name) clitest.SetupConfig(t, client, root) cmd.SetOut(stdoutBuf) @@ -73,7 +73,7 @@ func TestWorkspaceAutostart(t *testing.T) { _ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID) ) - cmd, root := clitest.New(t, "workspaces", "autostart", "enable", "doesnotexist") + cmd, root := clitest.New(t, "autostart", "enable", "doesnotexist") clitest.SetupConfig(t, client, root) err := cmd.Execute() @@ -91,7 +91,7 @@ func TestWorkspaceAutostart(t *testing.T) { _ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID) ) - cmd, root := clitest.New(t, "workspaces", "autostart", "disable", "doesnotexist") + cmd, root := clitest.New(t, "autostart", "disable", "doesnotexist") clitest.SetupConfig(t, client, root) err := cmd.Execute() @@ -118,7 +118,7 @@ func TestWorkspaceAutostart(t *testing.T) { currTz = "UTC" } expectedSchedule := fmt.Sprintf("CRON_TZ=%s 0 9 * * 1-5", currTz) - cmd, root := clitest.New(t, "workspaces", "autostart", "enable", workspace.Name) + cmd, root := clitest.New(t, "autostart", "enable", workspace.Name) clitest.SetupConfig(t, client, root) err := cmd.Execute() diff --git a/cli/workspaceautostop.go b/cli/autostop.go similarity index 82% rename from cli/workspaceautostop.go rename to cli/autostop.go index 2164e5be5ea03..a76dbb3f95c66 100644 --- a/cli/workspaceautostop.go +++ b/cli/autostop.go @@ -16,31 +16,30 @@ When enabling autostop, provide the minute, hour, and day(s) of week. The default autostop schedule is at 18:00 in your local timezone (TZ env, UTC by default). ` -func workspaceAutostop() *cobra.Command { +func autostop() *cobra.Command { autostopCmd := &cobra.Command{ Use: "autostop enable ", Short: "schedule a workspace to automatically stop at a regular time", Long: autostopDescriptionLong, - Example: "coder workspaces autostop enable my-workspace --minute 0 --hour 18 --days 1-5 -tz Europe/Dublin", + Example: "coder autostop enable my-workspace --minute 0 --hour 18 --days 1-5 -tz Europe/Dublin", Hidden: true, } - autostopCmd.AddCommand(workspaceAutostopEnable()) - autostopCmd.AddCommand(workspaceAutostopDisable()) + autostopCmd.AddCommand(autostopEnable()) + autostopCmd.AddCommand(autostopDisable()) return autostopCmd } -func workspaceAutostopEnable() *cobra.Command { +func autostopEnable() *cobra.Command { // yes some of these are technically numbers but the cron library will do that work var autostopMinute string var autostopHour string var autostopDayOfWeek string var autostopTimezone string cmd := &cobra.Command{ - Use: "enable ", - ValidArgsFunction: validArgsWorkspaceName, - Args: cobra.ExactArgs(1), + Use: "enable ", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { client, err := createClient(cmd) if err != nil { @@ -86,11 +85,10 @@ func workspaceAutostopEnable() *cobra.Command { return cmd } -func workspaceAutostopDisable() *cobra.Command { +func autostopDisable() *cobra.Command { return &cobra.Command{ - Use: "disable ", - ValidArgsFunction: validArgsWorkspaceName, - Args: cobra.ExactArgs(1), + Use: "disable ", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { client, err := createClient(cmd) if err != nil { diff --git a/cli/workspaceautostop_test.go b/cli/autostop_test.go similarity index 88% rename from cli/workspaceautostop_test.go rename to cli/autostop_test.go index 0e4f0b644bca7..0f3af1c2369c4 100644 --- a/cli/workspaceautostop_test.go +++ b/cli/autostop_test.go @@ -13,7 +13,7 @@ import ( "github.com/coder/coder/coderd/coderdtest" ) -func TestWorkspaceAutostop(t *testing.T) { +func TestAutostop(t *testing.T) { t.Parallel() t.Run("EnableDisableOK", func(t *testing.T) { @@ -28,7 +28,7 @@ func TestWorkspaceAutostop(t *testing.T) { _ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID) project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID) - cmdArgs = []string{"workspaces", "autostop", "enable", workspace.Name, "--minute", "30", "--hour", "17", "--days", "1-5", "--tz", "Europe/Dublin"} + cmdArgs = []string{"autostop", "enable", workspace.Name, "--minute", "30", "--hour", "17", "--days", "1-5", "--tz", "Europe/Dublin"} sched = "CRON_TZ=Europe/Dublin 30 17 * * 1-5" stdoutBuf = &bytes.Buffer{} ) @@ -47,7 +47,7 @@ func TestWorkspaceAutostop(t *testing.T) { require.Equal(t, sched, updated.AutostopSchedule, "expected autostop schedule to be set") // Disable schedule - cmd, root = clitest.New(t, "workspaces", "autostop", "disable", workspace.Name) + cmd, root = clitest.New(t, "autostop", "disable", workspace.Name) clitest.SetupConfig(t, client, root) cmd.SetOut(stdoutBuf) @@ -72,7 +72,7 @@ func TestWorkspaceAutostop(t *testing.T) { _ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID) ) - cmd, root := clitest.New(t, "workspaces", "autostop", "enable", "doesnotexist") + cmd, root := clitest.New(t, "autostop", "enable", "doesnotexist") clitest.SetupConfig(t, client, root) err := cmd.Execute() @@ -90,7 +90,7 @@ func TestWorkspaceAutostop(t *testing.T) { _ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID) ) - cmd, root := clitest.New(t, "workspaces", "autostop", "disable", "doesnotexist") + cmd, root := clitest.New(t, "autostop", "disable", "doesnotexist") clitest.SetupConfig(t, client, root) err := cmd.Execute() @@ -118,7 +118,7 @@ func TestWorkspaceAutostop(t *testing.T) { } expectedSchedule := fmt.Sprintf("CRON_TZ=%s 0 18 * * 1-5", currTz) - cmd, root := clitest.New(t, "workspaces", "autostop", "enable", workspace.Name) + cmd, root := clitest.New(t, "autostop", "enable", workspace.Name) clitest.SetupConfig(t, client, root) err := cmd.Execute() diff --git a/cli/cliui/agent.go b/cli/cliui/agent.go index 3770d07d5aecf..5d827bc1ec2a7 100644 --- a/cli/cliui/agent.go +++ b/cli/cliui/agent.go @@ -60,7 +60,7 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error { defer resourceMutex.Unlock() message := "Don't panic, your workspace is booting up!" if agent.Status == codersdk.WorkspaceAgentDisconnected { - message = "The workspace agent lost connection! Wait for it to reconnect or run: " + Styles.Code.Render("coder workspaces rebuild "+opts.WorkspaceName) + message = "The workspace agent lost connection! Wait for it to reconnect or run: " + Styles.Code.Render("coder rebuild "+opts.WorkspaceName) } // This saves the cursor position, then defers clearing from the cursor // position to the end of the screen. diff --git a/cli/workspacecreate.go b/cli/create.go similarity index 99% rename from cli/workspacecreate.go rename to cli/create.go index 678b55ee6dabc..e1d028511dd03 100644 --- a/cli/workspacecreate.go +++ b/cli/create.go @@ -14,7 +14,7 @@ import ( "github.com/coder/coder/codersdk" ) -func workspaceCreate() *cobra.Command { +func create() *cobra.Command { var ( workspaceName string templateName string diff --git a/cli/workspacecreate_test.go b/cli/create_test.go similarity index 93% rename from cli/workspacecreate_test.go rename to cli/create_test.go index 83118da5c7e48..447daf471fddd 100644 --- a/cli/workspacecreate_test.go +++ b/cli/create_test.go @@ -12,7 +12,7 @@ import ( "github.com/coder/coder/pty/ptytest" ) -func TestWorkspaceCreate(t *testing.T) { +func TestCreate(t *testing.T) { t.Parallel() t.Run("Create", func(t *testing.T) { t.Parallel() @@ -22,7 +22,7 @@ func TestWorkspaceCreate(t *testing.T) { version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) coderdtest.AwaitTemplateVersionJob(t, client, version.ID) template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) - cmd, root := clitest.New(t, "workspaces", "create", "my-workspace", "--template", template.Name) + cmd, root := clitest.New(t, "create", "my-workspace", "--template", template.Name) clitest.SetupConfig(t, client, root) doneChan := make(chan struct{}) pty := ptytest.New(t) @@ -52,7 +52,7 @@ func TestWorkspaceCreate(t *testing.T) { version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) coderdtest.AwaitTemplateVersionJob(t, client, version.ID) _ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) - cmd, root := clitest.New(t, "workspaces", "create", "my-workspace") + cmd, root := clitest.New(t, "create", "my-workspace") clitest.SetupConfig(t, client, root) doneChan := make(chan struct{}) pty := ptytest.New(t) @@ -82,7 +82,7 @@ func TestWorkspaceCreate(t *testing.T) { version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) coderdtest.AwaitTemplateVersionJob(t, client, version.ID) _ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) - cmd, root := clitest.New(t, "workspaces", "create", "") + cmd, root := clitest.New(t, "create", "") clitest.SetupConfig(t, client, root) doneChan := make(chan struct{}) pty := ptytest.New(t) @@ -134,7 +134,7 @@ func TestWorkspaceCreate(t *testing.T) { }) coderdtest.AwaitTemplateVersionJob(t, client, version.ID) _ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) - cmd, root := clitest.New(t, "workspaces", "create", "") + cmd, root := clitest.New(t, "create", "") clitest.SetupConfig(t, client, root) doneChan := make(chan struct{}) pty := ptytest.New(t) diff --git a/cli/workspacedelete.go b/cli/delete.go similarity index 81% rename from cli/workspacedelete.go rename to cli/delete.go index f3d68027661f7..7fa183b2b1df1 100644 --- a/cli/workspacedelete.go +++ b/cli/delete.go @@ -10,12 +10,12 @@ import ( "github.com/coder/coder/codersdk" ) -func workspaceDelete() *cobra.Command { +// nolint +func delete() *cobra.Command { return &cobra.Command{ - Use: "delete ", - Aliases: []string{"rm"}, - ValidArgsFunction: validArgsWorkspaceName, - Args: cobra.ExactArgs(1), + Use: "delete ", + Aliases: []string{"rm"}, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { client, err := createClient(cmd) if err != nil { diff --git a/cli/workspacelist.go b/cli/list.go similarity index 96% rename from cli/workspacelist.go rename to cli/list.go index 8e4118880b6b3..bb690b8c8209e 100644 --- a/cli/workspacelist.go +++ b/cli/list.go @@ -11,7 +11,7 @@ import ( "github.com/coder/coder/codersdk" ) -func workspaceList() *cobra.Command { +func list() *cobra.Command { return &cobra.Command{ Use: "list", Aliases: []string{"ls"}, @@ -31,7 +31,7 @@ func workspaceList() *cobra.Command { if len(workspaces) == 0 { _, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Prompt.String()+"No workspaces found! Create one:") _, _ = fmt.Fprintln(cmd.OutOrStdout()) - _, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render("coder workspaces create ")) + _, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render("coder create ")) _, _ = fmt.Fprintln(cmd.OutOrStdout()) return nil } diff --git a/cli/root.go b/cli/root.go index eaaa6787cf659..7aa247a41b2eb 100644 --- a/cli/root.go +++ b/cli/root.go @@ -67,17 +67,25 @@ func Root() *cobra.Command { cmd.SetVersionTemplate(versionTemplate()) cmd.AddCommand( + autostart(), + autostop(), configSSH(), - server(), + create(), + delete(), + gitssh(), + list(), login(), parameters(), + publickey(), + server(), + show(), + start(), + stop(), + ssh(), templates(), + update(), users(), - workspaces(), - ssh(), - workspaceTunnel(), - gitssh(), - publickey(), + tunnel(), workspaceAgent(), ) diff --git a/cli/workspaceshow.go b/cli/show.go similarity index 96% rename from cli/workspaceshow.go rename to cli/show.go index 98b77ace0f2ed..9b8a67abe46e6 100644 --- a/cli/workspaceshow.go +++ b/cli/show.go @@ -8,7 +8,7 @@ import ( "github.com/coder/coder/codersdk" ) -func workspaceShow() *cobra.Command { +func show() *cobra.Command { return &cobra.Command{ Use: "show", Args: cobra.ExactArgs(1), diff --git a/cli/workspacestart.go b/cli/start.go similarity index 88% rename from cli/workspacestart.go rename to cli/start.go index 5b985f7d88f0d..e672f25a213d9 100644 --- a/cli/workspacestart.go +++ b/cli/start.go @@ -10,11 +10,10 @@ import ( "github.com/coder/coder/codersdk" ) -func workspaceStart() *cobra.Command { +func start() *cobra.Command { return &cobra.Command{ - Use: "start ", - ValidArgsFunction: validArgsWorkspaceName, - Args: cobra.ExactArgs(1), + Use: "start ", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { client, err := createClient(cmd) if err != nil { diff --git a/cli/workspacestop.go b/cli/stop.go similarity index 89% rename from cli/workspacestop.go rename to cli/stop.go index cbf90c987c52b..7de514a0762d0 100644 --- a/cli/workspacestop.go +++ b/cli/stop.go @@ -10,11 +10,10 @@ import ( "github.com/coder/coder/codersdk" ) -func workspaceStop() *cobra.Command { +func stop() *cobra.Command { return &cobra.Command{ - Use: "stop ", - ValidArgsFunction: validArgsWorkspaceName, - Args: cobra.ExactArgs(1), + Use: "stop ", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { client, err := createClient(cmd) if err != nil { diff --git a/cli/templatecreate.go b/cli/templatecreate.go index 3505e94a37940..69c1b1af327b9 100644 --- a/cli/templatecreate.go +++ b/cli/templatecreate.go @@ -115,7 +115,7 @@ func templateCreate() *cobra.Command { "The "+cliui.Styles.Keyword.Render(templateName)+" template has been created! "+ "Developers can provision a workspace with this template using:")+"\n") - _, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render(fmt.Sprintf("coder workspaces create --template=%q [workspace name]", templateName))) + _, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render(fmt.Sprintf("coder create --template=%q [workspace name]", templateName))) _, _ = fmt.Fprintln(cmd.OutOrStdout()) return nil diff --git a/cli/tunnel.go b/cli/tunnel.go index a0b5cfc7c86d0..7f50abcd7d582 100644 --- a/cli/tunnel.go +++ b/cli/tunnel.go @@ -2,7 +2,7 @@ package cli import "github.com/spf13/cobra" -func workspaceTunnel() *cobra.Command { +func tunnel() *cobra.Command { return &cobra.Command{ Use: "tunnel", RunE: func(cmd *cobra.Command, args []string) error { diff --git a/cli/workspaceupdate.go b/cli/update.go similarity index 96% rename from cli/workspaceupdate.go rename to cli/update.go index 002b4496060b7..c3de8c2a36e75 100644 --- a/cli/workspaceupdate.go +++ b/cli/update.go @@ -9,7 +9,7 @@ import ( "github.com/coder/coder/codersdk" ) -func workspaceUpdate() *cobra.Command { +func update() *cobra.Command { return &cobra.Command{ Use: "update", RunE: func(cmd *cobra.Command, args []string) error { diff --git a/cli/usercreate.go b/cli/usercreate.go index dce69c080c8ee..899b8b4fb3d98 100644 --- a/cli/usercreate.go +++ b/cli/usercreate.go @@ -79,7 +79,7 @@ Run `+cliui.Styles.Code.Render("coder login "+client.URL.String())+` to authenti Your email is: `+cliui.Styles.Field.Render(email)+` Your password is: `+cliui.Styles.Field.Render(password)+` -Create a workspace `+cliui.Styles.Code.Render("coder workspaces create")+`!`) +Create a workspace `+cliui.Styles.Code.Render("coder create")+`!`) return nil }, } diff --git a/cli/workspaces.go b/cli/workspaces.go deleted file mode 100644 index 3ca5d03c4c52c..0000000000000 --- a/cli/workspaces.go +++ /dev/null @@ -1,51 +0,0 @@ -package cli - -import ( - "strings" - - "github.com/spf13/cobra" - - "github.com/coder/coder/codersdk" -) - -func workspaces() *cobra.Command { - cmd := &cobra.Command{ - Use: "workspaces", - Aliases: []string{"ws"}, - } - cmd.AddCommand(workspaceCreate()) - cmd.AddCommand(workspaceDelete()) - cmd.AddCommand(workspaceList()) - cmd.AddCommand(workspaceShow()) - cmd.AddCommand(workspaceStop()) - cmd.AddCommand(workspaceStart()) - cmd.AddCommand(ssh()) - cmd.AddCommand(workspaceUpdate()) - cmd.AddCommand(workspaceAutostart()) - cmd.AddCommand(workspaceAutostop()) - - return cmd -} - -func validArgsWorkspaceName(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) { - client, err := createClient(cmd) - if err != nil { - return nil, cobra.ShellCompDirectiveError - } - organization, err := currentOrganization(cmd, client) - if err != nil { - return nil, cobra.ShellCompDirectiveError - } - workspaces, err := client.WorkspacesByOwner(cmd.Context(), organization.ID, codersdk.Me) - if err != nil { - return nil, cobra.ShellCompDirectiveError - } - names := make([]string, 0) - for _, workspace := range workspaces { - if !strings.HasPrefix(workspace.Name, toComplete) { - continue - } - names = append(names, workspace.Name) - } - return names, cobra.ShellCompDirectiveDefault -} diff --git a/docs/README.md b/docs/README.md index a3c228ff36d5c..1cd14e0d0c8ee 100644 --- a/docs/README.md +++ b/docs/README.md @@ -59,7 +59,7 @@ coder templates create Create a workspace and connect to it via SSH: ```bash -coder workspaces create my-first-workspace +coder create my-first-workspace coder ssh my-first-workspace ``` diff --git a/docs/workspaces.md b/docs/workspaces.md index 8da4bfa789b10..4bb0723e307af 100644 --- a/docs/workspaces.md +++ b/docs/workspaces.md @@ -10,10 +10,10 @@ templates](./templates.md): ```sh # create a workspace from the template; specify any variables -coder workspaces create +coder create # show the resources behind the workspace, and how to connect -coder workspaces show +coder show ``` ## Connect with SSH @@ -72,5 +72,5 @@ Use the following command to update a workspace to the latest template version. The workspace will be stopped and started: ```sh -coder workspaces update +coder update ```