Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit438a51d

Browse files
committed
621 problems remaining...
1 parent274c84d commit438a51d

File tree

58 files changed

+191
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+191
-237
lines changed

‎cli/agent.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/coder/coder/codersdk/agentsdk"
2929
)
3030

31-
funcworkspaceAgent()*clibase.Cmd {
31+
func(r*RootCmd)workspaceAgent()*clibase.Cmd {
3232
var (
3333
authstring
3434
logDirstring

‎cli/clibase/cmd.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,20 @@ func RequireNArgs(want int) MiddlewareFunc {
245245
}
246246
}
247247

248+
funcRequireRangeArgs(start,endint)MiddlewareFunc {
249+
returnfunc(nextHandlerFunc)HandlerFunc {
250+
returnfunc(i*Invokation)error {
251+
iflen(i.Args)<start||len(i.Args)>end {
252+
returnfmt.Errorf(
253+
"wanted between %v and %v args but got %v",
254+
start,end,
255+
len(i.Args),
256+
)
257+
}
258+
returnnext(i)
259+
}
260+
}
261+
}
262+
248263
// HandlerFunc handles an Invokation of a command.
249264
typeHandlerFuncfunc(i*Invokation)error

‎cli/configssh.go‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,20 @@ func sshPrepareWorkspaceConfigs(ctx context.Context, client *codersdk.Client) (r
132132
}
133133
}
134134

135-
funcconfigSSH()*clibase.Cmd {
135+
func(r*RootCmd)configSSH()*clibase.Cmd {
136136
var (
137137
sshConfigFilestring
138138
sshConfigOptssshConfigOptions
139139
usePreviousOptsbool
140140
dryRunbool
141141
skipProxyCommandbool
142142
)
143+
varclient*codersdk.Client
143144
cmd:=&clibase.Cmd{
144145
Annotations:workspaceCommand,
145146
Use:"config-ssh",
146147
Short:"Add an SSH Host entry for your workspaces\"ssh coder.workspace\"",
147-
Example:formatExamples(
148+
Long:formatExamples(
148149
example{
149150
Description:"You can use -o (or --ssh-option) so set SSH options to be used for all your workspaces",
150151
Command:"coder config-ssh -o ForwardAgent=yes",
@@ -154,13 +155,11 @@ func configSSH() *clibase.Cmd {
154155
Command:"coder config-ssh --dry-run",
155156
},
156157
),
157-
Middleware:clibase.RequireNArgs(0),
158+
Middleware:clibase.Chain(
159+
clibase.RequireNArgs(0),
160+
r.useClient(client),
161+
),
158162
Handler:func(inv*clibase.Invokation)error {
159-
client,err:=useClient(cmd)
160-
iferr!=nil {
161-
returnerr
162-
}
163-
164163
recvWorkspaceConfigs:=sshPrepareWorkspaceConfigs(inv.Context(),client)
165164

166165
out:=inv.Stdout

‎cli/create.go‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/coder/coder/codersdk"
1717
)
1818

19-
funccreate()*clibase.Cmd {
19+
func(r*RootCmd)create()*clibase.Cmd {
2020
var (
2121
parameterFilestring
2222
richParameterFilestring
@@ -25,17 +25,14 @@ func create() *clibase.Cmd {
2525
stopAfter time.Duration
2626
workspaceNamestring
2727
)
28+
varclient*codersdk.Client
2829
cmd:=&clibase.Cmd{
2930
Annotations:workspaceCommand,
3031
Use:"create [name]",
3132
Short:"Create a workspace",
33+
Middleware:clibase.Chain(r.useClient(client)),
3234
Handler:func(inv*clibase.Invokation)error {
33-
client,err:=useClient(cmd)
34-
iferr!=nil {
35-
returnerr
36-
}
37-
38-
organization,err:=CurrentOrganization(cmd,client)
35+
organization,err:=CurrentOrganization(inv,client)
3936
iferr!=nil {
4037
returnerr
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-
funcprepWorkspaceBuild(cmd*clibase.Cmd,client*codersdk.Client,inv.ArgsprepWorkspaceBuildArgs) (*buildParameters,error) {
193+
funcprepWorkspaceBuild(cmd*clibase.Cmd,client*codersdk.Client,argsprepWorkspaceBuildArgs) (*buildParameters,error) {
197194
ctx:=inv.Context()
198195

199196
varuseRichParametersbool

‎cli/delete.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// nolint
13-
funcdeleteWorkspace()*clibase.Cmd {
13+
func(r*RootCmd)deleteWorkspace()*clibase.Cmd {
1414
varorphanbool
1515
cmd:=&clibase.Cmd{
1616
Annotations:workspaceCommand,
@@ -32,7 +32,7 @@ func deleteWorkspace() *clibase.Cmd {
3232
iferr!=nil {
3333
returnerr
3434
}
35-
workspace,err:=namedWorkspace(cmd,client,inv.Args[0])
35+
workspace,err:=namedWorkspace(inv.Context(),client,inv.Args[0])
3636
iferr!=nil {
3737
returnerr
3838
}

‎cli/dotfiles.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import (
1717
"github.com/coder/coder/cli/cliui"
1818
)
1919

20-
funcdotfiles()*clibase.Cmd {
20+
func(r*RootCmd)dotfiles()*clibase.Cmd {
2121
varsymlinkDirstring
2222
cmd:=&clibase.Cmd{
2323
Use:"dotfiles [git_repo_url]",
2424
Middleware:clibase.RequireNArgs(1),
2525
Short:"Checkout and install a dotfiles repository from a Git URL",
26-
Example:formatExamples(
26+
Long:formatExamples(
2727
example{
2828
Description:"Check out and install a dotfiles repository without prompts",
2929
Command:"coder dotfiles --yes git@github.com:example/dotfiles.git",

‎cli/gitaskpass.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818

1919
// gitAskpass is used by the Coder agent to automatically authenticate
2020
// with Git providers based on a hostname.
21-
funcgitAskpass()*clibase.Cmd {
21+
func(r*RootCmd)gitAskpass()*clibase.Cmd {
2222
return&clibase.Cmd{
2323
Use:"gitaskpass",
2424
Hidden:true,

‎cli/gitssh.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/coder/coder/cli/cliui"
1919
)
2020

21-
funcgitssh()*clibase.Cmd {
21+
func(r*RootCmd)gitssh()*clibase.Cmd {
2222
cmd:=&clibase.Cmd{
2323
Use:"gitssh",
2424
Hidden:true,
@@ -166,7 +166,7 @@ func parseIdentityFilesForHost(ctx context.Context, args, env []string) (identit
166166
// OpenSSH on Windows is weird, it supports using (and does
167167
// use) mixed \ and / in paths.
168168
//
169-
//Example: C:\Users\ZeroCool/.ssh/known_hosts
169+
//Long: C:\Users\ZeroCool/.ssh/known_hosts
170170
//
171171
// To check the file existence in Go, though, we want to use
172172
// proper Windows paths.

‎cli/list.go‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders
6464
}
6565
}
6666

67-
funclist()*clibase.Cmd {
67+
func(r*RootCmd)list()*clibase.Cmd {
6868
var (
6969
allbool
7070
defaultQuery="owner:me"
@@ -81,12 +81,8 @@ func list() *clibase.Cmd {
8181
Short:"List workspaces",
8282
Aliases: []string{"ls"},
8383
Middleware:clibase.RequireNArgs(0),
84+
Middleware:clibase.Chain(r.useClient(client)),
8485
Handler:func(inv*clibase.Invokation)error {
85-
client,err:=useClient(cmd)
86-
iferr!=nil {
87-
returnerr
88-
}
89-
9086
filter:= codersdk.WorkspaceFilter{
9187
FilterQuery:searchQuery,
9288
}

‎cli/login.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func init() {
3939
browser.Stdout=io.Discard
4040
}
4141

42-
funclogin()*clibase.Cmd {
42+
func(r*RootCmd)login()*clibase.Cmd {
4343
constfirstUserTrialEnv="CODER_FIRST_USER_TRIAL"
4444

4545
var (

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp