fix(cli): update plural resource mentions in generated help texts (#2918)
This commit is contained in:
1 parent
eea5e80fa2
commit
f88547bbf5
6 files changed
+31
-22
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
"github.com/iancoleman/strcase"
|
||||
)
|
||||
@@ -67,6 +68,10 @@ func hasAction(in []string, action string) bool {
|
||||
return strutil.StrListContains(in, action)
|
||||
}
|
||||
|
||||
func pluralString(in string) string {
|
||||
return lowerSpaceCase(resource.Map[in].PluralString())
|
||||
}
|
||||
|
||||
var cmdTemplate = template.Must(template.New("").Funcs(
|
||||
template.FuncMap{
|
||||
"camelCase": camelCase,
|
||||
@@ -75,6 +80,7 @@ var cmdTemplate = template.Must(template.New("").Funcs(
|
||||
"kebabCase": kebabCase,
|
||||
"lowerSpaceCase": lowerSpaceCase,
|
||||
"hasAction": hasAction,
|
||||
"pluralString": pluralString,
|
||||
},
|
||||
).Parse(`{{ $input := . }}
|
||||
// Code generated by "make cli"; DO NOT EDIT.
|
||||
@@ -273,7 +279,7 @@ func (c *{{ camelCase .SubActionPrefix }}Command) Run(args []string) int {
|
||||
c.plural = "{{ if .SubActionPrefix }}{{ kebabCase .SubActionPrefix }}-type {{ end }}{{ lowerSpaceCase .ResourceType }}"
|
||||
switch c.Func {
|
||||
case "list":
|
||||
c.plural = "{{ if .SubActionPrefix }}{{ kebabCase .SubActionPrefix }}-type {{ end }}{{ lowerSpaceCase .ResourceType }}s"
|
||||
c.plural = "{{ if .SubActionPrefix }}{{ kebabCase .SubActionPrefix }}-type {{ end }}{{ pluralString .ResourceType }}"
|
||||
}
|
||||
|
||||
f := c.Flags()
|
||||
|
||||
Reference in new issue
Block a user