Skip to content

Commit

Permalink
Add list of supported values for flags that represent an enum field (#…
Browse files Browse the repository at this point in the history
…1036)

## Changes
This PR adds the list of supported values for flags that represent an
enum field in the flag's documentation.
  • Loading branch information
shreyas-goenka committed Dec 6, 2023
1 parent e9ed828 commit a6752a5
Show file tree
Hide file tree
Showing 23 changed files with 123 additions and 45 deletions.
9 changes: 8 additions & 1 deletion .codegen/service.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ import (
{{skipThisFile}}
{{end}}

{{define "printArray" -}}
{{if le (len .) 5 -}}
[{{range $index, $element := .}}{{if ne $index 0}}, {{end}}{{$element.Name}}{{end}}]
{{- else -}}[{{range $index, $element := .}}
{{$element.Name}},{{end}}
]{{end}}{{end}}

{{define "service"}}
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
Expand Down Expand Up @@ -106,7 +113,7 @@ func new{{.PascalName}}() *cobra.Command {
{{else if .Entity.ArrayValue }}// TODO: array: {{.Name}}
{{else if .Entity.MapValue }}// TODO: map via StringToStringVar: {{.Name}}
{{else if .Entity.IsEmpty }}// TODO: output-only field
{{else if .Entity.Enum }}cmd.Flags().Var(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", `{{.Summary | without "`"}}`)
{{else if .Entity.Enum }}cmd.Flags().Var(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", `{{.Summary | without "`" | trimSuffix "."}}. Supported values: {{template "printArray" .Entity.Enum}}`)
{{else}}cmd.Flags().{{template "arg-type" .Entity}}(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", {{$method.CamelName}}Req.{{.PascalName}}, `{{.Summary | without "`"}}`)
{{end}}
{{- end -}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/account/groups/groups.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/account/log-delivery/log-delivery.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/account/private-access/private-access.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/account/service-principals/service-principals.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/account/users/users.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion cmd/account/workspaces/workspaces.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/workspace/catalogs/catalogs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/workspace/cluster-policies/cluster-policies.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 37 additions & 7 deletions cmd/workspace/clusters/clusters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/workspace/dashboards/dashboards.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions cmd/workspace/experiments/experiments.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/workspace/groups/groups.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a6752a5

Please sign in to comment.