commandlineparser / commandlineparser/commandline
After customizing help generation, hep VERB does not work
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 478
- PR merge metrics
- No merged PRs in 30d
Description
Did this
```
static async Task Main( string[] args )
{
_logger.Info(CommandLine.Text.HeadingInfo.Default);
var parser = new Parser(p => { p.AutoVersion = false; p.CaseInsensitiveEnumValues = true; });
var parserResult = parser.ParseArguments(args);
await parserResult.MapResult(
(SyncOptions opts) => SyncAsync(opts),
(QueryOptions opts) => QueryAsync(opts),
(TokenOptions opts) => ShowTokenAsync(opts),
errors => Task.FromResult(DisplayHelp(parserResult, errors))
)
.ContinueWith(t => {
if ( System.Diagnostics.Debugger.IsAttached )
{
Console.WriteLine("Press enter...");
Console.ReadLine();
}
});
}
private static int DisplayHelp( ParserResult result, IEnumerable errs )
{
var helpText = CommandLine.Text.HelpText.AutoBuild(result, h =>
{
h.AdditionalNewLineAfterOption = false;
h.AddNewLineBetweenHelpSections = true;
h.AddEnumValuesToHelpText = true;
h.AutoVersion = false;
h.Heading = CommandLine.Text.HeadingInfo.Empty;
h.MaximumDisplayWidth = 110;
h.AddVerbs(typeof(SyncOptions), typeof(QueryOptions), typeof(TokenOptions));
return CommandLine.Text.HelpText.DefaultParsingErrorsHandler(result, h);
}, e => e,
true);
Console.WriteLine(helpText);
return 1;
}
```
Before this I could type `MyProgram help VERB` and it would tell me the same as `MyProgram VERB` minus errors section. Now this gives me only verb list, like if `help` lost its first argument. This does not work either: `MyProgram VERB help` but this does: `MyProgram VERB --help`.
Am I doing something wrong here?
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the behavior with the commands shown, then start at Parser.ParseArguments and the custom DisplayHelp method using HelpText.AutoBuild and DefaultParsingErrorsHandler. Compare `MyProgram help VERB`, `MyProgram VERB help`, and `MyProgram VERB --help`; done means the intended verb-specific help is produced for the documented command without losing its argument.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100