-
Notifications
You must be signed in to change notification settings - Fork 401
expose HelpOption and HelpAction, move help configuration to the action #2102
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
Conversation
} | ||
|
||
internal HelpOption() : this("--help", new[] { "-h", "/h", "-?", "/?" }) | ||
public HelpOption() : this("--help", new[] { "-h", "/h", "-?", "/?" }) |
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.
Do you want to introduce something like HelpOption.DefaultAliases
and use it here for discoverability, etc.?
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.
How would it be used by the end users? Currently to get the default aliases they can just do new HelpOption().Aliases
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.
IIRC Krzysztof or Jeremy started this discussion and the context was that it was not clear what aliases the HelpOption
will use when created and added to the Command
.
In #2107 I've made the config mutable and simply added xml docs to the HelpOption
ctor:
command-line-api/src/System.CommandLine/Help/HelpOption.cs
Lines 8 to 18 in 2dd5b76
/// <summary> | |
/// When added to a <see cref="Command"/>, it configures the application to show help when one of the following options are specified on the command line: | |
/// <code> | |
/// -h | |
/// /h | |
/// --help | |
/// -? | |
/// /? | |
/// </code> | |
/// </summary> | |
public HelpOption() : this("--help", new[] { "-h", "/h", "-?", "/?" }) |
I am expecting that this is going to solve the problem
# Conflicts: # src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt # src/System.CommandLine.Tests/Invocation/InvocationPipelineTests.cs # src/System.CommandLine/Builder/CommandLineBuilder.cs # src/System.CommandLine/Builder/CommandLineBuilderExtensions.cs # src/System.CommandLine/CommandLineConfiguration.cs
If I wanted to specify the list of aliases of HelpOption (omitting "/h"), and set the maximum width, then what would be the most straightforward way to do both using this API? It seems UseHelp allows either of those customizations but not both. Should I avoid UseHelp altogether, and construct the HelpOption and HelpAction explicitly? |
Currently it would be: new HelpOption("--help", "-h")
{
Action = new HelpAction()
{
Builder = new HelpBuilder($width)
}
} FWIW we are not done with our work on help customization. Most probably I won't have the time to work on it before we release a new preview package (beginning of April), I am afraid it will have to wait until June. |
We now have two ways of configuring help:
Before parsing:
Or after: