-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: group subcommands in command help #675
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #675 +/- ##
==========================================
- Coverage 45.32% 44.76% -0.56%
==========================================
Files 179 179
Lines 7855 7952 +97
==========================================
Hits 3560 3560
- Misses 3842 3939 +97
Partials 453 453 ☔ View full report in Codecov by Sentry. |
c5ffb64
to
321842f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice documentation! Props to you.
Found some inconsistencies and missed subcommands.
What do you think about adding groups to the root command? rootCommand.AddGroup(&cobra.Group{ID: "resources", Title: "Resources:"})
rootCommand.AddCommand(
util.WithGroup("resources", all.NewCommand(s)),
util.WithGroup("resources", floatingip.NewCommand(s)),
util.WithGroup("resources", image.NewCommand(s)),
util.WithGroup("resources", server.NewCommand(s)),
util.WithGroup("resources", sshkey.NewCommand(s)),
util.WithGroup("resources", servertype.NewCommand(s)),
util.WithGroup("resources", datacenter.NewCommand(s)),
util.WithGroup("resources", location.NewCommand(s)),
util.WithGroup("resources", iso.NewCommand(s)),
util.WithGroup("resources", volume.NewCommand(s)),
util.WithGroup("resources", network.NewCommand(s)),
util.WithGroup("resources", loadbalancer.NewCommand(s)),
util.WithGroup("resources", loadbalancertype.NewCommand(s)),
util.WithGroup("resources", certificate.NewCommand(s)),
util.WithGroup("resources", firewall.NewCommand(s)),
util.WithGroup("resources", placementgroup.NewCommand(s)),
util.WithGroup("resources", primaryip.NewCommand(s)),
util.WithGroup("", version.NewCommand(s)),
util.WithGroup("", completion.NewCommand(s)),
util.WithGroup("", context.NewCommand(s)),
) Before & AfterBefore
After
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its awesome!
Just wanted to ask whether we prefer to use a manual sorting for the commands ?
Right now the command are sorted alphabetically, I think it will make more sense if we keep our own ordering.
I believe @phm07 was against this idea, @apricote what do you think?
Manage servers
Usage:
hcloud server [command]
General
list List Servers
describe Describe a server
create Create a server
delete Delete a server
update Update a Server
create-image Create an image from a server
change-type Change type of a server
rebuild Rebuild a server
add-label Add a label to a server
remove-label Remove a label from a server
Protection
enable-protection Enable resource protection for a server
disable-protection Disable resource protection for a server
Rescue
enable-rescue Enable rescue for a server
disable-rescue Disable rescue for a server
Power/Reboot
poweron Poweron a server
poweroff Poweroff a server
reboot Reboot a server
shutdown Shutdown a server
reset Reset a server
Networks
attach-to-network Attach a server to a network
detach-from-network Detach a server from a network
change-alias-ips Change a server's alias IPs in a network
set-rdns Change reverse DNS of a Server
ISO
attach-iso Attach an ISO to a server
detach-iso Detach an ISO from a server
Placement Groups
add-to-placement-group Add a server to a placement group
remove-from-placement-group Removes a server from a placement group
Backup
enable-backup Enable backup for a server
disable-backup Disable backup for a server
Additional Commands:
ssh Spawn an SSH connection for the server
ip Print a server's IP address
request-console Request a WebSocket VNC console for a server
reset-password Reset the root password of a server
metrics [ALPHA] Metrics from a Server
Flags:
-h, --help help for server
Global Flags:
--poll-interval duration Interval at which to poll information, for example action progress (default 500ms)
--quiet Only print error messages
Use "hcloud server [command] --help" for more information about a command.
@apricote I like the idea of adding groups to the root command. I'll add that in. @jooola We can already change the order of the groups, and inside the groups the commands are alphabetically sorted. I like that because it enforces consistent order inside of groups (for example for the General category, where commands are most often the same). Also, if you want to reorder commands inside of a group, that is probably a sign that they should go into their own group. |
I agree that consitency is a good thing, but if the ordering doesn't make much sens, maybe it worth perfecting the order by hand, for example the server general section:
|
Sooo, that means labels should be their own group? :D Its the one example that I found pretty annoying right now, because they are at the top and bottom of "General". I do agree that keeping it manually sorted is pretty annoying, but from a user perspective it looks way nicer (as long as that sorting is consistent between the commands). |
I'm not opposed to making the label commands have their own group |
I think that's the kind of work we have to do once, and its done. But I won't argue more than that. (to disable the sorting, you can set We could also sort the root commands by importance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
## [1.42.0](v1.41.1...v1.42.0) (2024-02-01) ### Features * add global --quiet flag to hide non-error messages ([#656](#656)) ([25fcbbf](25fcbbf)), closes [#644](#644) * allow adding/removing multiple labels at once ([#665](#665)) ([919c446](919c446)), closes [#662](#662) * group subcommands in command help ([#675](#675)) ([0cb271f](0cb271f)) * **server:** remove unsupported linux32 rescue type ([#679](#679)) ([5bb0350](5bb0350)) ### Bug Fixes * refetch after creating managed certificate ([#685](#685)) ([4864553](4864553)) * **server:** fix typo in ip subcommand ([#678](#678)) ([c5e3f00](c5e3f00)) * use --poll-interval flag ([#660](#660)) ([b9328a6](b9328a6))
This PR adds subcommand groups, which make the help output more structured and easier to read. Conventions on which groups to add and how to name them is also added.