Skip to content
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

Add Subcommand help headings #5819

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Fiedzia
Copy link

@Fiedzia Fiedzia commented Nov 14, 2024

Group subcommands displayed in help (#1553)
This is for help only, does not affect matching.

I've done the builder part, still figuring out derive support
(ah - it works automatically by setting subcommand_help_header=Some("foo"). I'd probably should just document it somewhere).

This is done the same way grouping args works: subcommand has optional subcommand_help_heading.
If provided, it will be used to group commands visually when displaying subcommand help.

so that we can go from

Commands:
cmd1 ...
cmd2 ...
help ...

to

Commands:
help ...

Utility commands:
cmd1 ...
cmd2 ....

Nothing changes if groups aren't used. See tests for examples.

Issues:
having subcommand_heading and subcommand_help_heading may be confusing, maybe naming should change.

@epage epage changed the title Command groups #1553 Add Subcommand help headings Nov 15, 2024
/// [`Command::subcommand_help_heading`]: crate::Command::subcommand_help_heading()
#[inline]
#[must_use]
pub fn next_subcommand_help_heading(mut self, heading: impl IntoResettable<Str>) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

This will also need a way to set the help heading for the current command

Copy link
Member

Choose a reason for hiding this comment

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

This will likely run into name conflicts with subcommand_help_heading. We should probably deprecate that and migrate people over to setting next_subcommand_help_heading.

/// [`Command::subcommand_help_heading`]: crate::Command::subcommand_help_heading()
#[inline]
#[must_use]
pub fn next_subcommand_help_heading(mut self, heading: impl IntoResettable<Str>) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

The derive has special handling for regular help headings, so we should probably have the same for these

/// [`Command::subcommand_help_heading`]: crate::Command::subcommand_help_heading()
#[inline]
#[must_use]
pub fn next_subcommand_help_heading(mut self, heading: impl IntoResettable<Str>) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

Should we only have one next_help_heading?

Copy link
Author

Choose a reason for hiding this comment

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

Good question, that would make api simpler, but I'd rather have clear separation between subcommand and parameter heading

Copy link
Member

Choose a reason for hiding this comment

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

Could you explain why?

Comment on lines +640 to +641
Commands:
help Print this message or the help of the given subcommand(s)
Copy link
Member

Choose a reason for hiding this comment

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

Before this can move forward, we need to come to a resolution on help. The initial discussion should be on #1553. If we need to make new issues off of that, then we can migrate from there.

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.

2 participants