Skip to content

feat: add support for Cobra command groups#33

Closed
dnapier wants to merge 5 commits intocharmbracelet:mainfrom
dnapier:add-command-groups
Closed

feat: add support for Cobra command groups#33
dnapier wants to merge 5 commits intocharmbracelet:mainfrom
dnapier:add-command-groups

Conversation

@dnapier
Copy link
Copy Markdown
Contributor

@dnapier dnapier commented Jun 19, 2025

Summary

• Adds support for organizing commands into groups using Cobra's command grouping functionality
• Allows developers to categorize related commands for better CLI organization and user experience

Test plan

  • Verify command groups display correctly in help output
  • Test that grouped commands function as expected
  • Ensure backward compatibility with existing command structure

Closes #32

- Add GroupedCommands struct to organize commands by group
- Implement evalGroupedCmds function to process command groups
- Update help rendering to display group headers
- Maintain backward compatibility for ungrouped commands
- Handle empty groups gracefully

Resolves charmbracelet#32
@dnapier dnapier requested a review from caarlos0 as a code owner June 19, 2025 13:22
@dnapier
Copy link
Copy Markdown
Contributor Author

dnapier commented Jun 19, 2025

Fixing linter errors.

caarlos0 added a commit that referenced this pull request Jun 23, 2025
- supports grouped commands (alternative impl of #33)
- fixes the help flag styles

Co-authored-by: David Napier <dnapier@users.noreply.github.com>
@caarlos0
Copy link
Copy Markdown
Contributor

made an alternative implementation at #42

added you as co-author as well!

thanks for the PR, btw <3

@caarlos0 caarlos0 closed this in #42 Jun 23, 2025
caarlos0 added a commit that referenced this pull request Jun 23, 2025
* feat: support grouped commands and fix flag style

- supports grouped commands (alternative impl of #33)
- fixes the help flag styles

Co-authored-by: David Napier <dnapier@users.noreply.github.com>

* fix: sort

* fix: keep original ordering

* fix: grouping

* fix: lint

* fix: double check

---------

Co-authored-by: David Napier <dnapier@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command Groups Not Displayed Properly in Fang

2 participants