mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
fix(cli/help): show deprecation notice properly for flags (#7904)
This commit is contained in:
committed by
GitHub
parent
a1c32954d9
commit
fa91e11105
25
cli/help.go
25
cli/help.go
@ -135,6 +135,31 @@ var usageTemplate = template.Must(
|
||||
"isDeprecated": func(opt clibase.Option) bool {
|
||||
return len(opt.UseInstead) > 0
|
||||
},
|
||||
"useInstead": func(opt clibase.Option) string {
|
||||
var sb strings.Builder
|
||||
for i, s := range opt.UseInstead {
|
||||
if i > 0 {
|
||||
if i == len(opt.UseInstead)-1 {
|
||||
_, _ = sb.WriteString(" and ")
|
||||
} else {
|
||||
_, _ = sb.WriteString(", ")
|
||||
}
|
||||
}
|
||||
if s.Flag != "" {
|
||||
_, _ = sb.WriteString("--")
|
||||
_, _ = sb.WriteString(s.Flag)
|
||||
} else if s.FlagShorthand != "" {
|
||||
_, _ = sb.WriteString("-")
|
||||
_, _ = sb.WriteString(s.FlagShorthand)
|
||||
} else if s.Env != "" {
|
||||
_, _ = sb.WriteString("$")
|
||||
_, _ = sb.WriteString(s.Env)
|
||||
} else {
|
||||
_, _ = sb.WriteString(s.Name)
|
||||
}
|
||||
}
|
||||
return sb.String()
|
||||
},
|
||||
"formatLong": func(long string) string {
|
||||
// We intentionally don't wrap here because it would misformat
|
||||
// examples, where the new line would start without the prior
|
||||
|
Reference in New Issue
Block a user