-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow full subcommand flag display
By default, only `required` flags are displayed for subcommands For applications with a lot of simple subcommands this obscures basic usage flags == Mitigation - Add a new `HelpOption` called `IncludeOptionalFlagsInSummary` - Move `Node.Summary()` functionality into `Node.SummaryWithOptions(bool)` - Retain `Node.Summary()` as a default usage (forwards default value to `Node.SummaryWithOptions(bool)`) - Modify `help.go@printCommandSummary()` to forward the `HelpOption` to `Node.SummaryWithOptions()` instead of calling `Node.Summary()` - Add tests for default and optional behaviour == Caveats The main issue with this implementation is due to the `Node` receiver functions doing display logic internally. This makes sense for most of the use cases (application error logic), but overly restricts the help configurability As a result: - Must pass awkward `bool` value down from the help context - `FlagSummary()` ends up having to explicitly exclude the `help` flag. == Potential improvements to be made - Remove explicit exclusion of `help` from `FlagSummary()` - Potentially add an equivalent `Node` receiver which just returns an array of flag summaries to be displayed by `help@printCommandSummary`
- Loading branch information
1 parent
195d56c
commit e37690f
Showing
3 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters