feat: add command headings feature
Implementing issue #1553
Scope of this PR
The objective for this PR is to provide a facility for the user to place their commands under a custom header to allow the grouping of commands such as might be seen in git --help.
The PR will not implement CommandAction which would be required to permit the user to replace the help command with a custom user help command which could be place under a custom header. The user can place help under a custom header by amending the default title using Command::subcommand_help_heading placing the help command and the updated section at the top of the list of commands.
The will not change the scope of the Command::next_help_heading to include processing for commands as this is a breaking change.
Design Statements
| Statement | Comment |
|---|---|
| MUST provide API to specify a custom section header for a user command | The key objective of the change |
| MUST keep commands with the same header together | |
| MUST display commands with no custom header under the default header | |
| MUST display help command under the standard header | To amend this the user should change the default header |
WILL NOT change scope of Command::next_help_heading to include subcommands |
|
WILL NOT deprecate Command::subcommand_help_heading |
It can be used to generate custom section heading for help |
| WILL NOT implement custom replacement of help | Future solution requiring CommandAction |
Please clean up the commits for how they should be reviewed and merged.
- there are extra commits from
masterthat were rewritten - builds are failing on early commits
there are extra commits from master that were rewritten
These commits are still around
Also, be sure to ping me when force-pushing; github doesn't send notifications for it.
@epage dropped the commits and force pushed
Please clean up commits for how they should be reviewed and merged and not for how this was implemented
@epage Amended and test for flatten introduced; changes introduced to ensure test passes
@epage comprehensive test suite added and valid. Flattened designed to place help at the end but non-flattened does not to allow the workaround of placing help under a renamed default heading. Rebased and force-pushed.
For a consistent approach of keeping the help at the end of the list of commands we will need to implement a solution that allows the user to specifically update the "help" command's heading. (Which, aligning with arg, is the Action solution).
@epage dropped the commits and force pushed
Please rebase against the latest master and drop the unrelated commits
@epage dropped the commits and force pushed
Please rebase against the latest master and drop the unrelated commits
Please see https://github.com/clap-rs/clap/pull/6183/commits for what I'm referring to
@epage dropped the commits and force pushed
Please rebase against the latest master and drop the unrelated commits
Please see https://github.com/clap-rs/clap/pull/6183/commits for what I'm referring to
@epage done.