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

Commit3f74426

Browse files
committed
review
1 parent4869325 commit3f74426

File tree

8 files changed

+27
-13
lines changed

8 files changed

+27
-13
lines changed

‎cli/restart.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func (r *RootCmd) restart() *serpent.Command {
2626
Short:"Restart a workspace",
2727
Middleware:serpent.Chain(
2828
serpent.RequireNArgs(1),
29-
PrintDeprecatedOptions(),
3029
r.InitClient(client),
3130
),
3231
Options: serpent.OptionSet{cliui.SkipPromptOption()},

‎cli/root.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,15 @@ func (r *RootCmd) Command(subcommands []*serpent.Command) (*serpent.Command, err
325325
}
326326
})
327327

328+
// Add the PrintDeprecatedOptions middleware to all commands.
329+
cmd.Walk(func(cmd*serpent.Command) {
330+
ifcmd.Middleware==nil {
331+
cmd.Middleware=PrintDeprecatedOptions()
332+
}else {
333+
cmd.Middleware=serpent.Chain(cmd.Middleware,PrintDeprecatedOptions())
334+
}
335+
})
336+
328337
ifr.agentURL==nil {
329338
r.agentURL=new(url.URL)
330339
}
@@ -1324,17 +1333,19 @@ func PrintDeprecatedOptions() serpent.MiddlewareFunc {
13241333
continue
13251334
}
13261335

1327-
warnStr:=translateSource(opt.ValueSource,opt)+" is deprecated, please use "
1336+
varwarnStr strings.Builder
1337+
_,_=warnStr.WriteString(translateSource(opt.ValueSource,opt))
1338+
_,_=warnStr.WriteString(" is deprecated, please use ")
13281339
fori,use:=rangeopt.UseInstead {
1329-
warnStr+=translateSource(opt.ValueSource,use)+" "
1340+
_,_=warnStr.WriteString(translateSource(opt.ValueSource,use))
13301341
ifi!=len(opt.UseInstead)-1 {
1331-
warnStr+="and "
1342+
_,_=warnStr.WriteString("and ")
13321343
}
13331344
}
1334-
warnStr+="instead.\n"
1345+
_,_=warnStr.WriteString("instead.\n")
13351346

13361347
cliui.Warn(inv.Stderr,
1337-
warnStr,
1348+
warnStr.String(),
13381349
)
13391350
}
13401351

@@ -1352,8 +1363,18 @@ func translateSource(target serpent.ValueSource, opt serpent.Option) string {
13521363
caseserpent.ValueSourceEnv:
13531364
returnfmt.Sprintf("`%s`",opt.Env)
13541365
caseserpent.ValueSourceYAML:
1355-
returnfmt.Sprintf("`%s`",opt.YAML)
1366+
returnfmt.Sprintf("`%s`",fullYamlName(opt))
13561367
default:
13571368
returnopt.Name
13581369
}
13591370
}
1371+
1372+
funcfullYamlName(opt serpent.Option)string {
1373+
varfull strings.Builder
1374+
for_,name:=rangeopt.Group.Ancestry() {
1375+
_,_=full.WriteString(name.YAML)
1376+
_,_=full.WriteString(".")
1377+
}
1378+
_,_=full.WriteString(opt.YAML)
1379+
returnfull.String()
1380+
}

‎cli/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
294294
Options:opts,
295295
Middleware:serpent.Chain(
296296
WriteConfigMW(vals),
297-
PrintDeprecatedOptions(),
298297
serpent.RequireNArgs(0),
299298
),
300299
Handler:func(inv*serpent.Invocation)error {

‎cli/ssh.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func (r *RootCmd) ssh() *serpent.Command {
7777
Middleware:serpent.Chain(
7878
serpent.RequireNArgs(1),
7979
r.InitClient(client),
80-
PrintDeprecatedOptions(),
8180
initAppearance(client,&appearanceConfig),
8281
),
8382
Handler:func(inv*serpent.Invocation) (retErrerror) {

‎cli/start.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func (r *RootCmd) start() *serpent.Command {
2525
Short:"Start a workspace",
2626
Middleware:serpent.Chain(
2727
serpent.RequireNArgs(1),
28-
PrintDeprecatedOptions(),
2928
r.InitClient(client),
3029
),
3130
Options: serpent.OptionSet{cliui.SkipPromptOption()},

‎cli/update.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ func (r *RootCmd) update() *serpent.Command {
2222
Long:"Use --always-prompt to change the parameter values of the workspace.",
2323
Middleware:serpent.Chain(
2424
serpent.RequireNArgs(1),
25-
PrintDeprecatedOptions(),
2625
r.InitClient(client),
2726
),
2827
Handler:func(inv*serpent.Invocation)error {

‎enterprise/cli/provisionerdaemonstart.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func (r *RootCmd) provisionerDaemonStart() *serpent.Command {
5858
Use:"start",
5959
Short:"Run a provisioner daemon",
6060
Middleware:serpent.Chain(
61-
agpl.PrintDeprecatedOptions(),
6261
// disable checks and warnings because this command starts a daemon; it is
6362
// not meant for humans typing commands. Furthermore, the checks are
6463
// incompatible with PSK auth that this command uses

‎enterprise/cli/proxyserver.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ func (r *RootCmd) proxyServer() *serpent.Command {
110110
Options:opts,
111111
Middleware:serpent.Chain(
112112
cli.WriteConfigMW(cfg),
113-
cli.PrintDeprecatedOptions(),
114113
serpent.RequireNArgs(0),
115114
),
116115
Handler:func(inv*serpent.Invocation)error {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp