Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acceptance/cmd/unknown-subcommand/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Usage:
databricks secrets [flags]
databricks secrets [command]

Available Commands
Available Commands:
create-scope Create a new secret scope.
delete-acl Delete an ACL.
delete-scope Delete a secret scope.
Expand Down
2 changes: 1 addition & 1 deletion acceptance/cmd/workspace/secrets/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage:
databricks secrets [flags]
databricks secrets [command]

Available Commands
Available Commands:
create-scope Create a new secret scope.
delete-acl Delete an ACL.
delete-scope Delete a secret scope.
Expand Down
2 changes: 1 addition & 1 deletion acceptance/pipelines/databricks-cli-help/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Usage:
databricks pipelines [flags]
databricks pipelines [command]

Available Commands
Main Commands
deploy Deploy pipelines
destroy Destroy a pipelines project
dry-run Validate correctness of the pipeline's graph
Expand Down
13 changes: 11 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@ const (
)

// configureGroups adds groups to the command, only if a group
// has at least one available command.
// has at least one available command. When only one group survives
// filtering, the grouping is dropped so Cobra's default "Available
// Commands" heading is used — matching commands that don't define
// groups at all.
func configureGroups(cmd *cobra.Command, groups []cobra.Group) {
filteredGroups := cmdgroup.FilterGroups(groups, cmd.Commands())
if len(filteredGroups) <= 1 {
for _, sub := range cmd.Commands() {
sub.GroupID = ""
}
return
}
for i := range filteredGroups {
cmd.AddGroup(&filteredGroups[i])
}
Expand Down Expand Up @@ -85,7 +94,7 @@ func New(ctx context.Context) *cobra.Command {
groups := []cobra.Group{
{
ID: mainGroup,
Title: "Available Commands",
Title: "Main Commands",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now a bit inconsistent with how Cobra behaves if there are no groups (it still prints Available Commands: in that case).

We could also do "Available Commands (Main)", "Available Commands (Permissions)", here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also applicable to the account commands?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inconsistency with Cobra is unfortunate. Any chance we can address that as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on Slack:

To get Cobra to print

Available Commands:
Main Commands
  get
  set

Permission Commands
  get-permission-levels

we'd need a custom template which is more maintenance than benefit here.

Renaming group 1 to Main is sufficient to avoid the confusion that there's more command groups below.

},
{
ID: pipelines.ManagementGroupID,
Expand Down
Loading