@@ -16,7 +16,7 @@ import (
1616"github.com/coder/coder/codersdk"
1717)
1818
19- func create ()* clibase.Cmd {
19+ func ( r * RootCmd ) create ()* clibase.Cmd {
2020var (
2121parameterFile string
2222richParameterFile string
@@ -25,17 +25,14 @@ func create() *clibase.Cmd {
2525stopAfter time.Duration
2626workspaceName string
2727)
28+ var client * codersdk.Client
2829cmd := & clibase.Cmd {
2930Annotations :workspaceCommand ,
3031Use :"create [name]" ,
3132Short :"Create a workspace" ,
33+ Middleware :clibase .Chain (r .useClient (client )),
3234Handler :func (inv * clibase.Invokation )error {
33- client ,err := useClient (cmd )
34- if err != nil {
35- return err
36- }
37-
38- organization ,err := CurrentOrganization (cmd ,client )
35+ organization ,err := CurrentOrganization (inv ,client )
3936if err != nil {
4037return err
4138}
@@ -193,7 +190,7 @@ type buildParameters struct {
193190
194191// prepWorkspaceBuild will ensure a workspace build will succeed on the latest template version.
195192// Any missing params will be prompted to the user. It supports legacy and rich parameters.
196- func prepWorkspaceBuild (cmd * clibase.Cmd ,client * codersdk.Client ,inv. Args prepWorkspaceBuildArgs ) (* buildParameters ,error ) {
193+ func prepWorkspaceBuild (cmd * clibase.Cmd ,client * codersdk.Client ,args prepWorkspaceBuildArgs ) (* buildParameters ,error ) {
197194ctx := inv .Context ()
198195
199196var useRichParameters bool