Skip to content

Commit

Permalink
Add documentation for positional args in commands generated from the …
Browse files Browse the repository at this point in the history
…Databricks OpenAPI specification (#1033)

## Changes
This PR adds documentation for positional arguments in commands that are
generated from the openapi spec.

Note: the changes to `.gitattributes` will be revert / properly fixed in
#1012
  • Loading branch information
shreyas-goenka authored Nov 30, 2023
1 parent bdef0f7 commit 7684017
Show file tree
Hide file tree
Showing 73 changed files with 1,714 additions and 356 deletions.
19 changes: 18 additions & 1 deletion .codegen/service.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,28 @@ func new{{.PascalName}}() *cobra.Command {
{{- $hasRequiredArgs := and (not $hasIdPrompt) $hasPosArgs -}}
{{- $hasSingleRequiredRequestBodyFieldWithPrompt := and (and $hasIdPrompt .Request) (eq 1 (len .Request.RequiredRequestBodyFields)) -}}

{{- $atleastOneArgumentWithDescription := false -}}
{{- if $hasPosArgs -}}
{{- range .Request.RequiredFields -}}
{{- if .HasComment -}}
{{- $atleastOneArgumentWithDescription = true -}}
{{- break -}}
{{- end -}}
{{- end -}}
{{- end -}}

cmd.Use = "{{.KebabName}}{{if $hasPosArgs}}{{range .Request.RequiredFields}} {{.ConstantName}}{{end}}{{end}}"
{{- if .Description }}
cmd.Short = `{{.Summary | without "`"}}`
cmd.Long = `{{.Comment " " 80 | without "`"}}`
cmd.Long = `{{.Comment " " 80 | without "`"}}
{{- if $atleastOneArgumentWithDescription }}

Arguments:
{{- range .Request.RequiredFields }}
{{ .ConstantName }}: {{.Comment " " 80 | without "`"}}
{{- end -}}
{{- end -}}
`
{{- end }}
{{- if .IsPrivatePreview }}

Expand Down
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,3 @@ cmd/workspace/warehouses/warehouses.go linguist-generated=true
cmd/workspace/workspace-bindings/workspace-bindings.go linguist-generated=true
cmd/workspace/workspace-conf/workspace-conf.go linguist-generated=true
cmd/workspace/workspace/workspace.go linguist-generated=true

# Hide diff for Go structs generated from databricks terraform provider schema
bundle/internal/tf/schema/*.go linguist-generated=true
18 changes: 16 additions & 2 deletions cmd/account/access-control/access-control.go

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

8 changes: 7 additions & 1 deletion cmd/account/billable-usage/billable-usage.go

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

10 changes: 8 additions & 2 deletions cmd/account/budgets/budgets.go

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

10 changes: 8 additions & 2 deletions cmd/account/credentials/credentials.go

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

15 changes: 12 additions & 3 deletions cmd/account/custom-app-integration/custom-app-integration.go

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

10 changes: 8 additions & 2 deletions cmd/account/encryption-keys/encryption-keys.go

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

20 changes: 16 additions & 4 deletions cmd/account/groups/groups.go

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

10 changes: 8 additions & 2 deletions cmd/account/ip-access-lists/ip-access-lists.go

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

15 changes: 13 additions & 2 deletions cmd/account/log-delivery/log-delivery.go

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

28 changes: 23 additions & 5 deletions cmd/account/metastore-assignments/metastore-assignments.go

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

15 changes: 12 additions & 3 deletions cmd/account/metastores/metastores.go

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

Loading

0 comments on commit 7684017

Please sign in to comment.