Skip to content

Commit 1b60191

Browse files
Rename Available Commands to Main Commands (#4975)
## Changes Rename command group `Available Commands` to `Main Commands`. With the rename, if only one command group survives filtering, drop it so Cobra can default to `Available Commands:` again. ## Why If `Management Commands` and/or `Permission Commands` groups are present, it is a bit confusing from `--help` that they are also available (because customers might stop parsing the list after the `Available Commands` heading group ends) before: ``` % databricks permissions --help Usage: databricks permissions [flags] databricks permissions [command] Available Commands get Get object permissions. set Set object permissions. update Update object permissions. Permission Commands get-permission-levels Get object permission levels. ``` after: ``` % ./cli permissions --help Usage: databricks permissions [flags] databricks permissions [command] Main Commands get Get object permissions. set Set object permissions. update Update object permissions. Permission Commands get-permission-levels Get object permission levels. Flags: -h, --help help for permissions ``` ## Tests manual, see Why section above ^ --------- Co-authored-by: simon <4305831+simonfaltum@users.noreply.github.com>
1 parent a802f4a commit 1b60191

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

acceptance/cmd/unknown-subcommand/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Usage:
99
databricks secrets [flags]
1010
databricks secrets [command]
1111

12-
Available Commands
12+
Available Commands:
1313
create-scope Create a new secret scope.
1414
delete-acl Delete an ACL.
1515
delete-scope Delete a secret scope.

acceptance/cmd/workspace/secrets/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Usage:
1515
databricks secrets [flags]
1616
databricks secrets [command]
1717

18-
Available Commands
18+
Available Commands:
1919
create-scope Create a new secret scope.
2020
delete-acl Delete an ACL.
2121
delete-scope Delete a secret scope.

acceptance/pipelines/databricks-cli-help/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Usage:
1818
databricks pipelines [flags]
1919
databricks pipelines [command]
2020

21-
Available Commands
21+
Main Commands
2222
deploy Deploy pipelines
2323
destroy Destroy a pipelines project
2424
dry-run Validate correctness of the pipeline's graph

cmd/cmd.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,18 @@ const (
3434
)
3535

3636
// configureGroups adds groups to the command, only if a group
37-
// has at least one available command.
37+
// has at least one available command. When only one group survives
38+
// filtering, the grouping is dropped so Cobra's default "Available
39+
// Commands" heading is used — matching commands that don't define
40+
// groups at all.
3841
func configureGroups(cmd *cobra.Command, groups []cobra.Group) {
3942
filteredGroups := cmdgroup.FilterGroups(groups, cmd.Commands())
43+
if len(filteredGroups) <= 1 {
44+
for _, sub := range cmd.Commands() {
45+
sub.GroupID = ""
46+
}
47+
return
48+
}
4049
for i := range filteredGroups {
4150
cmd.AddGroup(&filteredGroups[i])
4251
}
@@ -85,7 +94,7 @@ func New(ctx context.Context) *cobra.Command {
8594
groups := []cobra.Group{
8695
{
8796
ID: mainGroup,
88-
Title: "Available Commands",
97+
Title: "Main Commands",
8998
},
9099
{
91100
ID: pipelines.ManagementGroupID,

0 commit comments

Comments
 (0)